Date: Sat, 24 Aug 1996 12:39:33 +0300 (UKD) From: Igor Khasilev <igor@jabber.paco.odessa.ua> To: freebsd-hackers@freebsd.org Subject: Re: Non-blocking I/O on sockets and closed sockets? Message-ID: <199608240939.MAA26632@jabber.paco.odessa.ua> In-Reply-To: <9608231915.AA14731@pcnet1.pcnet.com> from "Daniel Eischen" at Aug 23, 96 03:15:20 pm
next in thread | previous in thread | raw e-mail | index | archive | help
> > I need to setup my sockets as non-blocking to avoid some problems, but > > it brings up a problem of determining if the remote end has closed the > > connection. Normally, if you run select() on a FD, and the subsequent > > read() call returns 0 you can assume the socket is dead. However, with > > non-blocking I/O a read of 0 does *NOT* mean the socket is dead. > > If the socket is non-blocking, then you should expect errno to be > EAGAIN on a read with no data present. You probably only need > something like this: > Another way is "read only if FD_ISSET for descriptor after select". Then 0 returned by read indicate EOF on socket. Igor
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608240939.MAA26632>
