Java TCP/IP Server - Client Communication over the internet

和自甴很熟 提交于 2020-01-05 10:37:20

问题


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.



来源:https://stackoverflow.com/questions/11243437/java-tcp-ip-server-client-communication-over-the-internet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!