delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/30/11:54:18

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: Wed, 30 Mar 2005 18:54:07 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: recv and errno during a connection reset/closed by peer
Message-ID: <20050330165407.GA7144@cygbert.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
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> <Pine DOT LNX DOT 4 DOT 60 DOT 0503291701210 DOT 736 AT gremlin DOT fruitbat DOT org> <Pine DOT CYG DOT 4 DOT 58 DOT 0503301014140 DOT 3732 AT fordpc DOT vss DOT fsi DOT com>
Mime-Version: 1.0
In-Reply-To: <Pine.CYG.4.58.0503301014140.3732@fordpc.vss.fsi.com>
User-Agent: Mutt/1.4.2i

On Mar 30 10:18, Brian Ford wrote:
> On Tue, 29 Mar 2005, Peter A. Castro wrote:
> 
> > On Tue, 29 Mar 2005, Brian Ford wrote:
> >
> > > 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.
> 
> I agree that zero length data can be sent, but only for UDP or datagram
> based sockets, not for TCP or stream based ones (nothing denotes a message
> here).  Even then, they are only sent by application choice, not just
> randomly by the OS.  Whether a connection is open or closed in this case
> has little meaning.

What Cygwin returns is what Cygwin gets from WinSock.  If Cygwin gets 0,
how should Cygwin suspect that something's wrong with the answer?  I'm
wondering how the OP has made sure that the connection has been closed
non-gracefully.  Has the process on the other side of the connection
been killed forcefully?  Or was the network cable plugged off?  Otherwise
there's a good chance that the process has closed the connection gracefully
and the 0 return is perfectly fine.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          mailto:cygwin AT cygwin DOT com
Red Hat, Inc.

--
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