Subject: Re: Dumb/silly network programming question
To: Paul Goyette <paul@whooppee.com>
From: Bill Studenmund <wrstuden@netbsd.org>
List: current-users
Date: 12/10/2003 15:29:28
--Sr1nOIr3CvdE5hEN
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Dec 09, 2003 at 07:14:20PM -0800, Paul Goyette wrote:
> 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.  :)

My code also is using O_NONBLOCK for reads.

> 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=3D-1 bytes read and errno=3DEAGAIN (=3D35).  At no ti=
me
> does the server's recv(2) return zero - always -1.

Oh.

You said "read" earlier. read(2) and recv(2) have different EOF semantics.

recv(2) does exactly what you are seeing. Its interface doesn't seem to be=
=20
able to indicate EOF.

Since you're using a TCP socket, I'd suggest using read(), not recv().

Take care,

Bill

--Sr1nOIr3CvdE5hEN
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iD8DBQE/16xYWz+3JHUci9cRAnMmAKCL7XIgUMKov2saSCXYNAeZIKtmdQCfTmzO
cappcUJsuS8NbCPNjcoIwWA=
=G7so
-----END PGP SIGNATURE-----

--Sr1nOIr3CvdE5hEN--