This is the mail archive of the
ecos-patches@sourceware.org
mailing list for the eCos project.
Re: Network TCP Handler: stale socket disposal
On 8/29/07, Andrew Lunn <andrew@lunn.ch> wrote:
> The full comment is:
>
> /*
> * We must not decommission a socket that's
> * on the accept(2) queue. If we do, then
> * accept(2) may hang after select(2) indicated
> * that the listening socket was ready.
> */
I wonder what "hang" means in this context. Does it just mean block?
What if the socket was set nonblocking?
My bible (Unix Network Programming, Vol.1) discusses this in some
detail in section 16.6. The example given there is (roughly) that if
a RST is received after the connection is established but before the
server has called accept(), then it will block in the accept() call
until a subsequent connection is made (on some platforms, including
Berkely-derived ones). The fix is to make the socket nonblocking and
to ignore certain errors.
This behavior may have changed since the book was written, of course...
Rob.