From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 25 01:03:30 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 875D737B401 for ; Fri, 25 Apr 2003 01:03:30 -0700 (PDT) Received: from mail.isg.siue.edu (mail.isg.siue.edu [146.163.5.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0B5443F75 for ; Fri, 25 Apr 2003 01:03:29 -0700 (PDT) (envelope-from wgrim@cougar.isg.siue.edu) Received: from WEBSHIELD1.isg.siue.edu (webshield1.isg.siue.edu [146.163.5.149]) by mail.isg.siue.edu (8.9.3p2/8.9.3) with SMTP id DAA03775 for ; Fri, 25 Apr 2003 03:03:24 -0500 (CDT) Received: From mail.isg.siue.edu ([146.163.5.4]) by WEBSHIELD1.isg.siue.edu (WebShield SMTP v4.5 MR1a); id 1051257803776; Fri, 25 Apr 2003 03:03:23 -0500 Received: from cougar (cougar [146.163.5.29]) by mail.isg.siue.edu (8.9.3p2/8.9.3) with ESMTP id DAA03762 for ; Fri, 25 Apr 2003 03:03:22 -0500 (CDT) Date: Fri, 25 Apr 2003 03:03:22 -0500 (CDT) From: William Michael Grim To: freebsd-hackers@freebsd.org In-Reply-To: <20030425.005750.43494308.imp@bsdimp.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: recv() returning 0 and EINTR on a still connection. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Apr 2003 08:03:30 -0000 I don't have the first message you sent out anymore. What actually happens when read() reaches EOF is that its file pointer stays at EOF. It doesn't actually close the file descriptor; you can juse as easily fseek to the BOF and read() again. I don't have the code from the first email, but wasn't he using recv() there? I suppose I could be mistaken on what he used. William Michael Grim Student, Southern Illinois University at Edwardsville Unix System Administrator, SIUE, Computer Science dept. Phone: (217) 341-6552 Email: wgrim@siue.edu On Fri, 25 Apr 2003, M. Warner Losh wrote: > In message: > William Michael Grim writes: > : I think your problem is that n==0 does NOT mean the connection was closed > : (at least not with TCP; I haven't really looked into other session > : protocols). > > I know that it does with FreeBSD, at least for read(2). > > : If n==0, it only means you have stopped receiving data because there is no > : more to be received; you can only trust errno if n==-1 or whatever the man > : page specifies for your OS (FreeBSD is -1 in this case). > > FreeBSD returns -1 and EWOULDBLOCK in this case. > > Warner >