开发者

Is it Possible to select the ephemeral port number for any CLient Program in java

When any client program communicates with server client uses an ephemeral port number to communi开发者_如何学Gocate with the server on server port. Is there any way to control/Select the client ephemeral port number in Java.


Yes, you specify the local address / portnumber:

Socket(InetAddress address, int port, InetAddress localAddr, int localPort)
      Creates a socket and connects it to the specified remote address on the specified remote port.

http://download.oracle.com/javase/6/docs/api/java/net/Socket.html#Socket%28java.net.InetAddress,%20int,%20java.net.InetAddress,%20int%29

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜