I'm very, very new to networking code, so my apologies in advance if this is a ridiculous question.
Using the standalone server code, I made a scene with a button that starts the server and a button that stops it. When I press the start server button, the ports are opened. (server.isActive is true). Debug log confirms it. When I hit stop server, it stops -- server.Stop(). The debug log shows the tcp and udp ports as 0.
But when I hit start server again, it claims the server is still active and says the ports are still open. I'm not sure what I'm doing wrong.
Start Server:private GameServer server
= new GameServer
();
Transform goTCPPort = transform.parent.FindChild("TCP Port");
int tcpPort = int.Parse (goTCPPort.FindChild ("Label").GetComponent<UILabel>().text);
Transform goUDPPort = transform.parent.FindChild("UDP Port");
int udpPort = int.Parse (goUDPPort.FindChild ("Label").GetComponent<UILabel>().text);
if(!server.isActive)
{
server.name = "My server";
server.Start(tcpPort, udpPort);
server.LoadFrom("server.dat");
Debug.Log("Server is active: " + server.isActive + " " + tcpPort + " " + udpPort);
}
else
{
Debug.Log("The ports are already open" + " " + tcpPort + " " + udpPort);
return;
}
Stop Server:server.SaveTo("server.dat");
server.Stop ();
Debug.Log("Server is active: " + server.isActive + " " + server.tcpPort + " " + server.udpPort);
return;
Thanks for any help you can provide.