Well, things aren't that clear to me:

1. I create a server socket to listen on port 9001.

2. I then check the local port used by this server socket (via the
getLocalPort method) and I get a different port number, value is 1050.
   (This in itself was unexpected. Shouldn't getLocalPort return the same
port I create the server socket with??)

3. I then accept a client connection, and then check the local port used by
the new socket on server side (again via the getLocalPort method), and it's
very much a different port number, value is 10531...

-- P

"Wan-Teh Chang" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Patrick wrote:
>
> > Here's a general question and it came about when I went to create a
> > SSLServerSocket in JSS:
> >
> > How can I control what port is used by the socket returned by the accept
> > method? (As you all know, after the server accepts a client connection,
it
> > creates a *brand new socket* which listens on *a brand new port*; this
is so
> > the server can continue listening to more clinet connections on the
original
> > socket...).
> >
> > Even in Sun's ServerSocket class, there seems to be no way...
> >
> > I know this is a fundamental socket programming issue, but I really
never
> > paid much attention to this issue until recently when my NSS app had a
> > requirement for staying within a pre-determined range for dynamically
> > allocated ports when creating any new socket...
>
>
> The socket returned by the accept method uses the same port
> that the original listening socket is using.
>
> Wan-Teh
>



Reply via email to