Hello,
I am using Unity 2018.1.5 to connect to my python server through TCP. I can only manage to connect when running client & server on the same machine and I am using port 50000. If I change the port to pretty much anything else OR if I try to run the unity executable on any other device on the network, I get no connection.
I have tried using my local ip “192.168.100.9”, my public IP and even a domain name. I have opened the correct ports on my router, and firefox/chrome can connect to my server from any device in the network without a problem.
So, the way I see it, unity is doing something that prevents other ports from working and cannot connect unless the server is running on the same machine. (I should mention that when running on the server machine, “localhost”, my local ip and my public ip all seem to work with unity).
The code I am using:
public String host = "localhost";
public int port = 50000;
try
{
tcp_socket = new TcpClient(host, port);
net_stream = tcp_socket.GetStream();
socket_writer = new StreamWriter(net_stream);
}
catch (Exception e)
{
// Something went wrong
Debug.Log("Socket error: " + e);
}