开发者

Java Socket Accept Connection from one IP

How to create a server socket which accept connection from a specific ip 开发者_如何学编程address?


new ServerSocket(1234, 50, InetAddress.getByName("1.2.3.4"));

Where 1234 - port 1.2.3.4 - the IP to listen to. So, if you have 2 IP addresses on 1 machine (1.2.3.4 and 1.2.3.5) the code above will subscribe to the first IP only.


Here is an example http://www.exampledepot.com/egs/java.nio/NbServerSocket.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜