Java TCP/IP Server - Client Communication over the

2019-07-23 06:14发布

问题:

I'd like to get a tcp/ip connection working over the internet. I already have two classes, one tcpserver which handles requests and a tcpclient which connects, sends and receives data.

Until now I had it working perfectly on local networks. The usual 127.0.0.1 / localhost and my 192.168.xxx.xxx adresses are not giving any problems.

My question is, what do I have to do to make it work over the internet. As I might want to do some research involving a simple http/server I need this to work.

I doubt its my firewall but maybe its the ISP that blocks this type of connection. Anybody has an idea?

回答1:

You need to open a port in the router that leads to the one that the server is listening on. You then connect to your public IP. This ip can be found on http://www.visaminip.se/



回答2:

To provide a service over the internet you need a public IP address. 10.x.x.x and 192.168.x.x are private networks. 127.x.x.x is for the local machine only.

The client can connect to the public IP address of a sepecific port.

The server's modem/router/firewalls allows this port to be open and passes traffic to your server on that port.



标签: java tcp ip