无法连接到互联网上的服务器
我有一个非常简单的java编写的客户端服务器代码(服务器侦听某个端口,客户端连接到服务器端口,建立连接后,客户端ip显示在服务器控制台上)。这个程序在内网中运行得很好,但是如果客户端和服务器都在互联网上,我的服务器无法检测到它。我的客户端和服务器上没有安装防火墙,端口转发是在服务器上完成的(我可以从canyouseeme.org看到它) )。
服务器与其他三台计算机直接连接到调制解调器(它们也直接连接到调制解调器)
请帮我弄清楚为什么我无法在互联网上检测到客户端。提前致谢。
Client code:
------------
String remoteIP = //remote ip
int port =1888;
try{
new Socket(remoteIp,port);
}catch(Exception e){
System.out.println(e.message());
}
Server code
-----------
ServerSocket serversocket = new ServerSocket(port);
Socket socket = serverSocket.accept();
displayIp(socket);
I have a very simple client server code written java(server listens on some port and client connects to server port and after connection is established, client ip is displayed on server console). This program is working very well in intranet, but if client and server are on internet, my server cannot detect it.I have no firewall installed on my client and server and port forwarding is done on server(I can see it from canyouseeme.org).
Server is directly connected to modem along with other three computers(they are also connected to modem directly)
Please help me figure out why I am not able to detect client on internet.Thanks in advance.
Client code:
------------
String remoteIP = //remote ip
int port =1888;
try{
new Socket(remoteIp,port);
}catch(Exception e){
System.out.println(e.message());
}
Server code
-----------
ServerSocket serversocket = new ServerSocket(port);
Socket socket = serverSocket.accept();
displayIp(socket);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查客户端的代理配置,请参阅 http:// /download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
您使用哪种协议?
Check your proxy configurations on the client side, see http://download.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
Which protocol do you use?