java 通过套接字连接到远程系统

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4922136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 08:37:54  来源:igfitidea点击:

Connect to remote system through socket

javasockets

提问by Jinith

Am trying to connect to a remote system which is not in the same local area as mine through java sockets, can anyone share some sample code or docs to do so.

我正在尝试通过 java 套接字连接到与我不在同一本地区域的远程系统,任何人都可以共享一些示例代码或文档来这样做。

I have created a server socket and is listening for connection at a port.how can i connect to that socket from my client program that is not in the same local area network as the server.

我已经创建了一个服务器套接字并正在侦听端口上的连接。如何从与服务器不在同一局域网中的客户端程序连接到该套接字。

Thanks in advance..

提前致谢..

采纳答案by William

http://www.oracle.com/technetwork/java/socket-140484.htmlprovides both server and client examples of connecting to a socket.

http://www.oracle.com/technetwork/java/socket-140484.html提供了连接到套接字的服务器和客户端示例。