I need to bind my client within a specific port range, a range that is a
subset of the OS' range. That's why I cannot let the OS pick one at random.
Unless of course, there's a way to configure the OS so that it picks ports
from a specific range...

-- P

"Wan-Teh Chang" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Patrick wrote:
>
> > 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)
>
>
> Correct.  But one does not need to bind a client-side socket.
>
>
> > 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...
>
>
> You have not stated why you want to bind a client-side socket.
> If you don't need to bind a client-side socket, I do have a
> smarter way to do this -- do not bind a client socket, let
> the OS pick an unused port for you, and call getsockname to
> find out which port the socket is bound to.
>
> Wan-Teh
>



Reply via email to