Network Connect to self after initializing server

Hi there, i´m currently making a multiplayer game, and i want the player to create a server and join that server immediately. As it is now, the player hosts a server, opens up another instance of the game and joins there.

Creating and joining is currently working.

//The player hosts a server after typing in the name of the server and Port he wants to use default port is 25600
if(creating = true)

{

    Network.InitializeServer(8,Connection_Port,false);

}

// The player starts an extra game instance and joins, after typing in the IP and Port to connect to. Default is IP: 127.0.0.1, Port: 25600.
if (Joining = true)

{

   Network.Connect(Connect_To_Ip,Connection_Port);

}

But this does not work:

//The player Creates a server after choosing Servername and Portnumber.
if(creating = true)

{

    Network.InitializeServer(8,Connection_Port,false);
    Network.Connect("127.0.0.1",Connection_Port);

}

ive got “Network.connections.Length” to show and is only counting 1 if i join with another instance. No errors occurs.

Getting this error: “The connection request to 127.0.0.1:26500 failed. Are you sure the server can be connected to?”

The player hosting the server is already connected to that server. You cannot connect to another game while you are a server so your second Network.Connect will either fail or shut down the server.

Now i get it. The host can play on the server himself, i just never let him, i just showed him a host admin page instead of the playing field :slight_smile:

i just found this after some more searching: Ports and Networking problem - Questions & Answers - Unity Discussions

Bunny83: “You can never connect to yourself with Unity’s network system because you can only be server OR client. The only way is to start your game two times and let one be the server and the other a client…”