Udo, Do you have Steven's UNIX Network Programming Vol 1 2ed? If not you should. ISBN 0-13-490012-X Section 15.6 says: 1. always set a listening socket nonblocking if we use select() to tell us when a connection is ready to be accept()'ed and 2. ignore the following errors on the subsequent call to accept(): EWOULDBLOCK (for Berkeley-derived implementations, when the client aborts the connection), ECONNABORTED (for POSIX 1.g implementations, when the client aborts the connection), EPROTO (for SVR4 implementations, when the client aborts the connection), and EINTR (if signals are begin caught). Hope this helps. Tuan On Thu, 8 Mar 2001, Udo A. Steinberg wrote: > > Hi all, > > Consider the following scenario in a userspace app, while > establishing a tcp connection. > > 1. SYN, SYN/ACK, ACK (connection accepted) > 2. select/poll wakes up > 3. RST arrives (connection aborted) > 4. user calls accept() > > Under Linux accept won't fail with ECONNABORTED, but sockaddr > will be filled with garbage (or be not filled in at all). > > What is the correct way to detect this scenario? Checking the > contents of sockaddr for sa_len == 0 or sa_family == 0 or > calling getsockopt (fd, SOL_SOCKET, SO_ERROR, ...)? > > -Udo. > - > : send the line "unsubscribe linux-net" in > the body of a message to majordomo@vger.kernel.org > -- Tuan Hoang The MITRE Corporation tuan@optimus.mitre.org - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org