服务器连接不工作
我用 Java 编写了自己的服务器,但我有点菜鸟。客户端程序通过 TCP 连接连接到我的 IP 地址的端口 5000。当我在同一台计算机上运行服务器和客户端时,它会连接并且服务器说传入的 IP 地址是 127.0.0.1 - localhost。当我在单独的计算机上运行客户端时,它永远不会连接。我知道我不久前通过更改一些路由器设置解决了这个问题,但我忘记了如何解决。有人可以简单地向我解释如何解决这个问题吗?我的路由器是 Verizon 的,我使用的是 Windows Vista。
I wrote my own server in Java and I'm kind of a noob. The client program connects to my IP Address at port 5000 over a TCP connection. When I run the server and the client on the same machine, it connects and the server is saying the incoming IP Adress is 127.0.0.1 - localhost. When I run the client on a seperate machine, it never connects. I know I fixed this problem a while ago by changing some router settings but I forget how. Could someone explain to me in simple terms how to fix this? My router is verizon and I'm using Windows Vista.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在远程计算机上运行客户端,但您的服务器被 ISP 的路由器“屏蔽”,那么您必须更改路由器上的设置。基本上,您必须对您的路由器说:如果外部有人想要通过端口 xyz 联系我,那么,亲爱的路由器,请将其转发到我的计算机。该术语通常是“端口转发”、“非军事区”、“传入连接”、“网络地址转换 (NAT)”或类似的内容。
注意:反过来也没有问题:如果您想要连接到外部服务器,路由器会自动管理。
If you run the client on the remote machine but your server is "shielded" by a router from your ISP, then you must change the settings on the router. Basically you must say to your router: If someone from the outside wants to reach me on port xyz, then, dear router, please forward this to my computer. The term is ususually "Port Forwarding", "Demilitarized Zone", "Incoming Connections", "Network Address Translation (NAT)" or something like that.
Note: The other way around is no problem: If YOU want to connect to a server on the outside, the router manages that automatically.