Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 86784 invoked from network); 5 Mar 2004 00:04:20 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 5 Mar 2004 00:04:20 -0000 Received: (qmail 86193 invoked by uid 500); 5 Mar 2004 00:04:04 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 86155 invoked by uid 500); 5 Mar 2004 00:04:03 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 86141 invoked from network); 5 Mar 2004 00:04:03 -0000 In-Reply-To: <20040304225150.GA11421@gideon.its.monash.edu.au> References: <20040304225150.GA11421@gideon.its.monash.edu.au> Mime-Version: 1.0 (Apple Message framework v612) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <9DEF615E-6E38-11D8-9E65-000A95891440@slamb.org> Content-Transfer-Encoding: 7bit Cc: dev@apr.apache.org From: Scott Lamb Subject: Re: PATCH: Determine how many bytes are waiting to be read from a socket Date: Thu, 4 Mar 2004 18:04:05 -0600 To: Robert Norris X-Mailer: Apple Mail (2.612) X-Spam-Checker-Version: SpamAssassin 2.61 (1.212.2.1-2003-12-09-exp) on calvin.slamb.org X-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00 autolearn=no version=2.61 X-Spam-Level: X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Mar 4, 2004, at 4:51 PM, Robert Norris wrote: > Attached is a patch that adds a function apr_socket_pending(). This > allows the caller to find out how many bytes are waiting to be read > from > a socket without actually reading those bytes. > > I use this to determine if the peer has closed the connection. In that > case, the socket goes readable, and this function reports 0 bytes > waiting. I don't think this is correct. select() and similar functions can return spuriously, at least on some platforms[*]. I would imagine this would return 0 in such a case, and the socket would not have closed. Why not just do the read and see if it returns 0? [*] - http://cr.yp.to/docs/unixport.html Scott