delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/29/20:12:48

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Tue, 29 Mar 2005 17:10:36 -0800 (PST)
From: "Peter A. Castro" <doctor AT fruitbat DOT org>
To: cygwin AT cygwin DOT com
cc: Peter Stephens <ptfoof AT sbcglobal DOT net>
Subject: RE: recv and errno during a connection reset/closed by peer
In-Reply-To: <Pine.CYG.4.58.0503291036300.3732@fordpc.vss.fsi.com>
Message-ID: <Pine.LNX.4.60.0503291701210.736@gremlin.fruitbat.org>
References: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAUKQItienSEKG+9226yKd5cKAAAAQAAAADZbnjoLqKEeI3+lfe/tpAgEAAAAA AT sbcglobal DOT net> <Pine DOT LNX DOT 4 DOT 60 DOT 0503281549130 DOT 736 AT gremlin DOT fruitbat DOT org> <Pine DOT CYG DOT 4 DOT 58 DOT 0503291036300 DOT 3732 AT fordpc DOT vss DOT fsi DOT com>
MIME-Version: 1.0
X-IsSubscribed: yes

On Tue, 29 Mar 2005, Brian Ford wrote:

> On Mon, 28 Mar 2005, Peter A. Castro wrote:
>
>> As someone who's seen this behaviour on several platforms, it can happen.
>> I've had to deal with this little annoyance in other products by having a
>> retry counter loop.  So many consecutive recv()s of 0 length constitues a
>> closed connection.  Something like this might work here as well?
>
> If you are doing a normal blocking recv without MSG_PEEK, any return of 0
> should mean a closed connection AFAIK.

Unfortunately that's not true for all implementation.  It's legal for a
zero length data object to be sent.  The network simply sends a header
with no payload in it, but it's passed through the network anyways and is
presented to the receiver.  The receiver, which might be blocking at the
time, will return from the call and get zero length data, but the
connection is still valid at this point.  I've seen AS/400's do just this
sending zero length data to an AIX box.  If the sender closes the
connection normally, then subsequent calls to recv return zero with no
indication that the connection is closed.  Call it a bug if you want, but
that's how it works.

> --
> Brian Ford

-- 
Peter A. Castro <doctor AT fruitbat DOT org> or <Peter DOT Castro AT oracle DOT com>
 	"Cats are just autistic Dogs" -- Dr. Tony Attwood

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019