Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Wed, 30 Mar 2005 10:18:35 -0600
From: Brian Ford <ford@vss.fsi.com>
Reply-To: cygwin@cygwin.com
To: "Peter A. Castro" <doctor@fruitbat.org>
cc: cygwin@cygwin.com, Peter Stephens <ptfoof@sbcglobal.net>
Subject: RE: recv and errno during a connection reset/closed by peer
In-Reply-To: <Pine.LNX.4.60.0503291701210.736@gremlin.fruitbat.org>
Message-ID: <Pine.CYG.4.58.0503301014140.3732@fordpc.vss.fsi.com>
References: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAUKQItienSEKG+9226yKd5cKAAAAQAAAADZbnjoLqKEeI3+lfe/tpAgEAAAAA@sbcglobal.net> <Pine.LNX.4.60.0503281549130.736@gremlin.fruitbat.org> <Pine.CYG.4.58.0503291036300.3732@fordpc.vss.fsi.com> <Pine.LNX.4.60.0503291701210.736@gremlin.fruitbat.org>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
X-OriginalArrivalTime: 30 Mar 2005 16:18:39.0710 (UTC) FILETIME=[22292FE0:01C53544]

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.

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
the best safety device in any aircraft is a well-trained pilot...

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

