Re: Communicating with a servlet using NIO?
- From: George Neuner <gneuner2/@/comcast.net>
- Date: Fri, 07 Dec 2007 18:45:52 -0500
On Thu, 06 Dec 2007 05:42:28 GMT, Esmond Pitt
George Neuner wrote:
constantly in a busy system. Not only do most programs let the system
select outgoing ports, but the system also selects the incoming ports
for most server programs.
This is not correct. TCP/IP uses the same port number as the listening
port for incoming connections.
When a connection is made to a TCP
listen port, the system selects a free port and transfers the incoming
connection to it - all communication beyond the initial connection by
the client takes place through that randomly assigned port.
This is not correct. See above.
Sorry, but it is you who are wrong. Look in your help or man pages
for the description of the "accept" call.
You may be thinking that sockets can be shared and multiplexed - which
is true - but that's not how the accept call works.
<QUOTE> from FreeBSD man page accept(2)
Accept removes the next connection request from the queue (or waits
until a connection request arrives), creates a new socket for the
request, and returns the descriptor for the new socket. Accept only
applies to stream sockets (e.g., those used with TCP).
<QUOTE> from Linux man page accept(2)
The accept() system call is used with connection-based socket types
(SOCK_STREAM, SOCK_SEQPACKET). It extracts the first connection
request on the queue of pending connections, creates a new connected
socket, and returns a new file descriptor referring to that socket.
The newly created socket is not in the listening state. The original
socket sockfd is unaffected by this call.
<QUOTE> from Winsock2 SDK
The accept function extracts the first connection on the queue of
pending connections on socket s. It then creates and returns a handle
to a new socket. The newly created socket is the socket that will
handle the actual connection; it has the same properties as socket s,
including the asynchronous events registered with the WSAAsyncSelect
or WSAEventSelect functions.
I don't have an AT&T Unix derivative handy to quote from its man page.
The basic TLI calls are similar to BSD in that t_listen sets the
connection point to passive mode and t_accept creates and returns a
new stream endpoint. The details are different because TLI allows
compositions of streams and filters in a way that's very similar to
the way Java handles streams.
In 20+ years I've worked with a half dozen versions of Unix, with
Linux, with MacOS (before the Unix versions), with every version of
Windows and with three different RTOS's. I've never encountered any
TCP implementation in which accept did not create a new socket.
for email reply remove "/" from address
- Prev by Date: Re: how to obtain heap dump on demand on windows and JRE 1.5.0_9 ?
- Next by Date: Re: abstract vs. final
- Previous by thread: Re: Communicating with a servlet using NIO?
- Next by thread: Re: Communicating with a servlet using NIO?