The question is answered, right answer was accepted
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("127.0.0.1",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("127.0.0.1", 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();
netConfig.AddChannel(QosType.Reliable);
and is used by both the NetworkClient and NetworkServer.
Searched the docs and cannot see anything. Anyone able to offer suggestions, answers?
Thanks
Answer by LinkoVitch · Sep 09, 2015 at 07:41 PM
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 :)
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.
HTH
Follow this Question
Related Questions
Unet - whats the best approach for a global game manager? 0 Answers
When Do SyncLists get Initialized? 0 Answers
Synchronize scene loading networking 1 Answer
Issuing SetClientReady causes duplicate network objects on local client 1 Answer
Not able to instantiate an object on the Client using [Command] UNET 0 Answers