Wan-Teh Chang wrote: > Patrick wrote: > >> Is there a way to find an unused local port for when I create a client >> socket, or is trial and error? > > This is done by the OS. You don't need to bind a client socket.
Here's a more detailed explanation for JSS sockets. Some SSLSocket constructors take a localPort parameter, allowing you to bind your client socket to a specific local port. If you specify 0 for this parameter, the OS will pick an unused port for you. If you call one of the SSLSocket constructors that does not take the localPort parameter, again the OS will pick an unused port for you. http://www.mozilla.org/projects/security/pki/jss/javadoc/org/mozilla/jss/ssl/SSLSocket.html Perhaps you're trying to do something more complicated. Maybe you want your client port to be in some specific range? I don't know of any nice way to accomplish this.
