Unable to connect on socket across different networks.
- by maleki
I am having trouble connecting my online application to others across another network. I am able to give them the hostAddress to connect when we are on the same network but when we are doing it across the internet the generated host address doesn't allow a connection, nor does using the ip address gotten from online sites such as whatismyip.com
My biggest issue isn't debugging this code, because it works over intra-network but The server doesn't see attempts when we try to move to different networks. Also, the test ip I am using is 2222.
InetAddress addr = InetAddress.getLocalHost();
String hostname = addr.getHostName();
System.out.println("Hostname: " + hostname);
System.out.println("IP: " + addr.getHostAddress());
I display the host to the server when it is starting
if (isClient) {
System.out.println("Client Starting..");
clientSocket = new Socket(host, port_number);
} else {
System.out.println("Server Starting..");
echoServer = new ServerSocket(port_number);
clientSocket = echoServer.accept();
System.out.println("Warning, Incoming Game..");
}