I need to make a server and a client that connects to the server.
Problem : "the server is running, the client can only connect to localhost, it cannot connect to the server on the Internet. I want the client to connect to the server through the public ip address on which the server is located."
First of all, I made sure that the port is redirected and accessible, I checked the port, and secondly, I completely disabled the firewall from the server machine.
below is the test code I'm using:
Server: nothing unusual is simple - ends if the client is connected, otherwise it just waits for a connection.
public class Server { public static void main(String args[]) { try { ServerSocket srvr = new ServerSocket(52000); srvr.accept(); } catch(Exception e) { e.printStackTrace(); } } }
Client: I used no-ip.com to mask the ip server on "biogenserver2.noip.me". Using .getCanonicalHostName (); will return ip.
public class Client { public static void main(String args[]) { try { String ip = Inet4Address.getByName("somets.noip.com").getCanonicalHostName(); InetSocketAddress sa = new InetSocketAddress(ip, 52000);
When I start this server, the server connects perfectly, but the client returns a "connection timeout" exception
Any help would be appreciated. Thanks.
source share