Well, one can certainly pick which local port to bind to. In JSS for
example, there are a few SSLSocket constructors that allow a localPort to be
specified (See
http://www.mozilla.org/projects/security/pki/jss/javadoc/org/mozilla/jss/ssl
/SSLSocket.html#constructor_summary)

However one does not know in advance what local ports are unused. As it
stands now, I pick a random port and try to bind. If I get a bind error, I
try again with another randomly selected port number...This works but does
look very smart. So Im thinking there's got to be a smarter way to do
this...(And more generally, I wonder how an OS picks which port to bind the
client socket to? Does it also do this by trial and error? I guess it would
depend on the OS...)

-- P

"Wan-Teh Chang" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> 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.
>
> Wan-Teh
>



Reply via email to