I’m trying to use NetworkTransport to establish a connection between two separate machines. But any connection attempt from the client to the server is not seen by the server. I tried different socketPorts, but nothing works and I’m stumped. Can anyone see what is wrong?
On both client and server I run this to initialize:
private void initNetwork() {
NetworkTransport.Init();
ConnectionConfig config = new ConnectionConfig();
c1 = config.AddChannel(QosType.Reliable);
topology = new HostTopology(config, 10);
hostId = NetworkTransport.AddHost(topology, socketPort);
}
Then, on the client, I run this to request a connection. I get no errors (NetworkError.OK )
connectionId = NetworkTransport.Connect(hostId, serverIp, socketPort, 0, out err);
The server is listening for incoming calls like this (called from Update) but it never gets anything other than NetworkEventType.Nothing
private void handleServer() {
int recHostId;
int connectionId;
int channelId;
int dataSize;
byte error;
byte[] workingBuffer = new byte[1024];
byte[] recBuffer;
NetworkEventType recData = NetworkTransport.Receive(out recHostId, out connectionId, out channelId, workingBuffer, workingBuffer.Length, out dataSize, out error);
if (recData == NetworkEventType.Nothing)
return;
// it never gets here
Debug.Log("Event: " + recData.ToString());
recBuffer = new byte[dataSize];
if (dataSize > 0) {
Buffer.BlockCopy(workingBuffer, 0, recBuffer, 0, dataSize);
}
switch (recData) {
case NetworkEventType.ConnectEvent: Debug.Log("Connected!"); break;
case NetworkEventType.DisconnectEvent: Debug.Log("Disconnected!"); break;
case NetworkEventType.DataEvent: Debug.Log("Data!"); break;
}
}