Re: (none)

From: Miquel van Smoorenburg <miquels@dont-contact.us>
Date: 11 Nov 1997 11:09:07 +0100

In article <01bcee84$619ffd20$4b4175c3@haven>,
Steven Jurczyk <steve@top.pl> wrote:
>Hi!
>My name is Steven Jurczyk and I'm writting small Web server. It use the some
>technology as Squid (no forking, select). All works fine but I have one
>problem. Using select I can detect that I can read/write to specified
>socket. But how detect that specified socket was closed (for example socket
>to CGI).

A closed socket is marked ready for reading. read() then returns `0' to
indicate the socket was closed.

Don't let yourself be fooled by the "exception" fd_set; that's for catching
OOB data (MSG_OOB). Something you'll probably never need.

Also, you want to make sure all your sockets are non-blocking and check
for read/write returning -1 and errno set to EWOULDBLOCK. That can be
kind of tricky (but it feels really great once you get it to work).

Mike.

-- 
   Miquel van      | Cistron Internet Services   --    Alphen aan den Rijn.
   Smoorenburg,    | mailto:info@cistron.nl          http://www.cistron.nl/
miquels@cistron.nl |       PTT's Het Net: Surfen in de gootsteen!	<*>
Received on Tue Nov 11 1997 - 02:15:21 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:37:29 MST