This is the mail archive of the
mailing list for the Cygwin project.
RE: recv and errno during a connection reset/closed by peer
- From: "Peter Stephens" <ptfoof at sbcglobal dot net>
- To: "'Peter A. Castro'" <doctor at fruitbat dot org>
- Cc: <cygwin at cygwin dot com>
- Date: Mon, 28 Mar 2005 23:55:33 -0500
- Subject: RE: recv and errno during a connection reset/closed by peer
The most likely reason for the difference in Cygwin is,
"If you create a socket using the Winsock 2 WSASocket API and you need to
apply a timeout in receive or send operations on the socket, you must
specify the WSA_FLAG_OVERLAPPED flag in the WSASocket call."
>From the MSDN website article
Peter A. Stephens
From: Peter A. Castro [mailto:email@example.com]
Sent: Monday, March 28, 2005 7:02 PM
To: Peter Stephens
Subject: RE: recv and errno during a connection reset/closed by peer
On Mon, 28 Mar 2005, Peter Stephens wrote:
> Are you saying that there is no way to distinguish a dropped
> connection from a MSG_PEEK with no data to retrieve?
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?
> P.S. I use this standard: http://www.unix.org/unix03.html . Is this
Brians' link is to the Single Unix Spec V2, so it's not all that old.
> Peter A. Stephens
> -----Original Message-----
> From: Brian Ford [mailto:firstname.lastname@example.org]
> Sent: Monday, March 28, 2005 11:37 AM
> To: Peter Stephens
> Cc: email@example.com
> Subject: RE: recv and errno during a connection reset/closed by peer
> On Fri, 25 Mar 2005, Peter Stephens wrote:
>> I boiled this down to nothing(see below). I must be missing
>> something basic.
>> I tried the suggestions made so far and it never gets to:
>> printf(" >>> ERRNO %i\n", errno);
>> I would expect that on a disconnect (I use putty in telnet or raw
>> mode) it would return -1 whether it is doing MSG_PEEK or an actual
>> retrieval. No luck.
> Nope (http://www.opengroup.org/onlinepubs/7990989775/xns/recv.html):
> "If no messages are available to be received and the peer has
> performed an orderly shutdown, recv() returns 0."
> I think that's what you're missing.
> 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/
Peter A. Castro <firstname.lastname@example.org> or <Peter.Castro@oracle.com>
"Cats are just autistic Dogs" -- Dr. Tony Attwood
ADR;WORK:;;712 West Sycamore;;;46901
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:712 West Sycamore=0D=0A46901
ADR;HOME:;;712 West Sycamore;Kokomo;Indiana;46901;United States of America
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:712 West Sycamore=0D=0AKokomo, Indiana 46901=0D=0AUnited States of America
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html