Subject: Re: Dumb/silly network programming question
To: Bill Studenmund <>
From: Paul Goyette <>
List: current-users
Date: 12/09/2003 19:14:20
Remember, the socket is set to O_NONBLOCK since I don't want writes
to stall and I'm too lazy to keep toggling O_NONBLOCK on for write,
off for read.  :)

When the client is SIGKILLed, the server's select(2) returns with the
socket's fd's bit set in the readmask.  Each read, first or more,
returns with retval=-1 bytes read and errno=EAGAIN (=35).  At no time
does the server's recv(2) return zero - always -1.

The client's socket gets stalled in FIN_WAIT2 state for a few minutes,
waiting for the server to finish, and the server's socket gets stalled
in CLOSE_WAIT indefinitely;  since it never tries to send anything
(sends are only in response to whatever was received from the client)
the server never notices that the connection was aborted.

On Tue, 9 Dec 2003, Bill Studenmund wrote:

> On Tue, Dec 09, 2003 at 06:30:46PM -0800, Paul Goyette wrote:
> > Yup.  I verified, and I get return value of -1 for the read, and errno
> > is set to EAGAIN.  This is on the first read after the other end of the
> > connection has been SIGKILLed.  I do NOT get a return value of zero,
> > that was a typo in the original post.
> Weird. I get 0 in my app.
> SIGKILL will end up calling close() on the socket.
> What happens the next time you read?
> Take care,
> Bill

|   Paul Goyette   | PGP DSS Key fingerprint: |  E-mail addresses:   |
| Network Engineer | FA29 0E3B 35AF E8AE 6651 |   |
|  & World Cruiser | 0786 F758 55DE 53BA 7731 | |