delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/30/23:57:07

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 20:54:31 -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 peert
In-Reply-To: <Pine.CYG.4.58.0503301029410.3732@fordpc.vss.fsi.com>
Message-ID: <Pine.LNX.4.60.0503301941480.527@gremlin.fruitbat.org>
References: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAUKQItienSEKG+9226yKd5cKAAAAQAAAAdWX/pT74GUisDog/o7TE3gEAAAAA AT sbcglobal DOT net> <Pine DOT CYG DOT 4 DOT 58 DOT 0503291040080 DOT 3732 AT fordpc DOT vss DOT fsi DOT com> <Pine DOT LNX DOT 4 DOT 60 DOT 0503291711560 DOT 736 AT gremlin DOT fruitbat DOT org> <Pine DOT CYG DOT 4 DOT 58 DOT 0503301029410 DOT 3732 AT fordpc DOT vss DOT fsi DOT com>
MIME-Version: 1.0
X-IsSubscribed: yes

On Wed, 30 Mar 2005, Brian Ford wrote:

> On Tue, 29 Mar 2005, Peter A. Castro wrote:
>> On Tue, 29 Mar 2005, Brian Ford wrote:
>>> On Tue, 29 Mar 2005, Peter Stephens wrote:
>>>> I have thought about your suggestion and it makes a lot of sense.
>>>>
>>>> It seems like your suggestion would be very portable.  A good
>>>> suggestion and the most likely route for me at this point.
>>>
>>> Not to me.  Maybe I'm missing something, but it seems you are going to a
>>> lot of effort to poorly recreate poll/select?
>>
>> Why?
>
> A zero length return on a stream socket always means that the peer has
> closed its socket for writing.  It may, however, still be open for
> reading (I don't remember the syscalls for doing such, but it can be
> done).

And I'm saying experience shows to the contrary.

> A zero return on a datagram socket always means that a zero length
> message has been received.

We're talking stream, not datagram here.

> Counting zero returns is a poor hack at best and makes no sense to me
> since it never gives you any more information.

Considering its a very simply solution to a real problem, what makes it a
poor hack?

>> If you are doing sequential, non multi-plexed, reads why do poll or
>> select?
> You don't need to.
>> Sitting in read is more optimal and the read should return
>> either data or an error.
> Ok.
>> The flaw in recv is that it returns a non-error non-data status.
> It's not a flaw, it's the design (see above).

Yes, and I've never been very happy with it.  If the connection was
closed and there's no more data left to return, I'd prefer recv returned
-1 with ENODATA or ENOTCONN for the errno.  But, it's not likely recv's
semantics will ever be changed.

>> Perhaps it would be better to switch to using read() instead of recv?
> They usually have exactly the same semantics.

Note the word "usually".  Not "always".

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