From owner-freebsd-hackers Sat Aug 24 02:47:51 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id CAA24395 for hackers-outgoing; Sat, 24 Aug 1996 02:47:51 -0700 (PDT) Received: from jabber.paco.odessa.ua (jabber.paco.odessa.ua [193.124.52.20]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id CAA24268 for ; Sat, 24 Aug 1996 02:43:49 -0700 (PDT) Received: (from igor@localhost) by jabber.paco.odessa.ua (8.7.1/8.6.10/01) id MAA26632 for freebsd-hackers@freebsd.org; Sat, 24 Aug 1996 12:39:33 +0300 (UKD) From: Igor Khasilev Message-Id: <199608240939.MAA26632@jabber.paco.odessa.ua> Subject: Re: Non-blocking I/O on sockets and closed sockets? To: freebsd-hackers@freebsd.org Date: Sat, 24 Aug 1996 12:39:33 +0300 (UKD) In-Reply-To: <9608231915.AA14731@pcnet1.pcnet.com> from "Daniel Eischen" at Aug 23, 96 03:15:20 pm X-Mailer: ELM [version 2.4 PL24] Content-Type: text Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > > 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