Subject: listen queue

From: "D'laila Pereira" <[email-masked]>
Date: Sun, 5 Nov 2000 14:00:24 -0600 (CST)

When the TCP on the server side receives a SYN during the three way
handshake
the listen (...) command will allocate a buffer and place the IP address
and port number of the client sending the SYN into the buffer
What data structure should be used to create this buffer in case of BSD
implemenations?

thanks
D'laila

---

From: der Mouse <[email-masked]>
Date: Mon, 13 Nov 2000 12:53:54 -0500 (EST)

> handshake the listen (...) command will allocate a buffer and place
> the IP address and port number of the client sending the SYN into the
> buffer

Since you mention listen(), I assume you're talking about the BSD
socket API.  (TCP and the socket API are orthogonal to one another;
neither one implies the other.)

And in that case, your description is somewhat confused.  listen()
ensures that the socket will accept connections; it doesn't place
anything from an incoming SYN anywhere - listen() is called before the
incoming SYN arrives.

> What data structure should be used to create this buffer in case of
> BSD implemenations?

I'm not sure what you're asking here.  Your use of "should" implies
that there is choice, which means you must be talking about userland
code, since the kernel code either does or doesn't use any particular
structure - there is no "should" for it.  And if you're talking about a
userland buffer for the peer address, then *none* of the socket calls
will allocate it; it is passed as an argument to the various calls that
use it (accept(), getpeername(), etc).

The most plausible explanation that comes to mind is that you meant
accept(), not listen(), in which case the argument is typed as a
"struct sockaddr", and you should use the AF-specific struct
appropriate to the AF of the socket (probably struct sockaddr_in,
corresponding to AF_INET).

Also, in this case, your question contains an inaccuracy; accept() does
not return until the three-way handshake has been completed, rather
than doing anything when the first SYN arrives.

					der Mouse

			       [email-masked]
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B