Subject: Re: Dumb/silly network programming question
To: Paul Goyette <email@example.com>
From: Bill Studenmund <firstname.lastname@example.org>
Date: 12/11/2003 09:35:15
Content-Type: text/plain; charset=us-ascii
On Wed, Dec 10, 2003 at 04:20:09PM -0800, Paul Goyette wrote:
> On Wed, 10 Dec 2003, Bill Studenmund wrote:
> > Since you're using a TCP socket, I'd suggest using read(), not recv().
> Well, since I'm emulating the telnet protocol, I have to be able to
> handle Out-of-Band data (flags argument=3DMSG_OOB), too, corresponding to
> TCP's Urgent flag (unless I've made another blunder). I don't see a
> way to deal with MSG_OOB using read().
True. You won't get OOB data.
> Anyway, I've managed to work around it by checking for retval=3D=3D-1 and
> errno=3D=3DEAGAIN, and sending a Telnet IAC-NOP sequence to the client.
> The write detects the broken socket and shuts things down on the server
Another idea is after recv() returns EAGAIN, try a read of one byte. Then=
that can see an EOF.
Since you're using select (and I assume eventually kqueue), you should=20
only be looking at a socket that has something on it. You really never=20
should see EAGAIN; if select's working right, to not be able to read would=
imply the other side unsent data. :-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)
-----END PGP SIGNATURE-----