From dev-return-17076-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Wed Aug 16 15:36:56 2006 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 11313 invoked from network); 16 Aug 2006 15:36:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Aug 2006 15:36:55 -0000 Received: (qmail 5647 invoked by uid 500); 16 Aug 2006 15:36:54 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 5609 invoked by uid 500); 16 Aug 2006 15:36:54 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 5598 invoked by uid 99); 16 Aug 2006 15:36:54 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Aug 2006 08:36:54 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [65.99.219.155] (HELO haxent.com) (65.99.219.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Aug 2006 08:36:52 -0700 Received: from [192.168.1.100] (unknown [201.10.81.238]) by haxent.com (Postfix) with ESMTP id 6CA163088C; Wed, 16 Aug 2006 12:36:30 -0300 (BRT) In-Reply-To: <5c902b9e0608160700s58c9dd3end6610105bb9190bd@mail.gmail.com> References: <44D113D0.9080001@apache.org> <11a09c160608021747u50575660x92a5fd2d478586b2@mail.gmail.com> <44D26800.5040402@apache.org> <11a09c160608031523j11ae7f38t9c2da95c2ddce62d@mail.gmail.com> <5c902b9e0608160001p64d0b25ane3e3884e3396c052@mail.gmail.com> <20060816075544.GA31747@redhat.com> <20060816132437.GP2515@scotch.ics.uci.edu> <2AFD4B10-5388-48B2-93E0-7E0585AC88A0@haxent.com.br> <5c902b9e0608160700s58c9dd3end6610105bb9190bd@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Message-Id: Cc: dev@apr.apache.org Content-Transfer-Encoding: quoted-printable From: Davi Arnaut Subject: Re: [Fwd: Re: How to detect is the socket is still open] Date: Wed, 16 Aug 2006 12:36:23 -0300 To: Justin Erenkrantz X-Mailer: Apple Mail (2.752.2) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Em 16/08/2006, =E0s 11:00, Justin Erenkrantz escreveu: > On 8/16/06, Davi Arnaut wrote: >> The only portable way to "detect" a broken connection is using >> SO_KEEPALIVE >> or to write/read "ping" data through the socket -- which is what >> keepalive does. > > How would SO_KEEPALIVE help? The other end is deliberately closing > the connection and we need to know that. It would help detect a broken connection, not a RST state. > Would a non-blocking read() followed by a poll()/select() be useful? > We'd still get a 0 back from read() - but if it was the EOF, would the > state of the socket change to be in the 'exceptional' state then if we > repoll? -- justin Humm, read returning 0 is a EOF, you could also maybe getsockopt(SO_ERROR) on the socket to confirm the EOF. Upon receive of a RST the socket should move to the closed state, and poll should return immediately if the POLLHUP mask was passed for that socket, and SO_ERROR should be one of ECONNREFUSED (syn sent)/EPIPE (close wait)/ECONNRESET or none if the socket was already closed. Select is a different beast because of the definition of what is a "exceptional condition" which may be pending error conditions or oob data. I think the "exception fd" of select is similar to a poll with POLLPRI mask, so it shoud'nt signal a connection reset. -- Davi Arnaut