[ee122] listen()

vern at cs.berkeley.edu vern at cs.berkeley.edu
Sun Nov 25 18:28:21 PST 2007


> My understanding of these methods (and I'm sure Prof Paxson will
> correct me if I'm wrong), is that listen() examines the socket,
> looking for incoming SYNs.  It doesn't respond to the SYNs but leaves
> them as half-open connections (in state SYN-RECEIVED).

Almost.  It does in fact respond to the SYNs, per my previous note.
This is necessary to ensure that any time the listen socket shows 
a new connection available via accept(), it's guaranteed that there
is indeed a connection available, meaning that a 3-way TCP handshake
has completed.

> accept()
> handles the rest of the handshake and moves the TCP connection into
> the ESTABLISHED state.

If accept() dealt with the rest of the handshake, then it would need
a way to indicate that the handshake failed.  The return codes from
the API don't include this (though they could've, so what you sketch
would make for a reasonable design).

		Vern


More information about the ee122 mailing list