Establishing a local connection to server

I am reworking my network code having implemented a mostly working system using NetworkManager as a basis, I am reworking this to provide the same functionality without using the NetworkManager class itself.

I have managed to implement what seems to be a working server and client set of classes and can pass messages back and forth as I had done previously, however I cannot replicate the local connection that was possible with the StartHost method of NetworkManager.

When I created a connection with StartHost the connection id would be ‘-1’ indicating that it was using the internal queues to pass traffic. using NetworkClient.Connect(“”,portno) creates an IP connection instead. Does anyone know what the correct incantation is to create a local client connection to the local server?

My current code works for remote clients as well as a local client connecting via the loopback address.

I have tried:

Network.Client("", portno); // Connects but as an IP connection
NetworkClient.Connect(null, portno);    // null object error at Runtime
NetworkClient.Connect("localhost", portno);  // Connects but as an IP connection
NetworkClient.Connect("", portno); // Connect Error: 11 !!  possibly something here?

my ConnectionConfig object is very simple:

	netConfig = new ConnectionConfig();

and is used by both the NetworkClient and NetworkServer.

Searched the docs and cannot see anything. Anyone able to offer suggestions, answers?


Some more digging and I have a solution to this. I’ll post it here in case someone else has the same problem as me :slight_smile:

To establish a local connection to the local host use the ClientScene class (!?) EG

NetworkClient netC;

netC = ClientScene.ConnectLocalServer();

This will connect to the local host and return the NetworkClient that is attached to that connection. It won’t trigger a MsgType.Connect on your NetworkServer host however, but will trigger one on your NetworkClient.

As these are the same physical machine I exposed the necessary method within my NetworkServer handling class to finish up the connection.