Re: How do you get ECONNRESET on recv?



On 2007-08-09, chsalvia@xxxxxxxxx <chsalvia@xxxxxxxxx> wrote:
The man page for recv and read list the error ECONNRESET as an error
condition that happens when "A connection was forcibly closed by a
peer." I take this to mean that, assuming a TCP connection, if a
client is recv'ing from a server, and the server suddenly crashes,
then on the client side recv will return -1 and set errno to
ECONNRESET.

Well, your understanding is probably wrong.

The TCP answers with RESET when you try to send some data to peer that
does not want to read that data. In other words the peer has closed
connection or has done shutdown of reading.

Normally, if the peer closes connection, recv returns 0 without any
error. The same applies to the cases when the peer application crashes.

Now, if you try to send the data to peer after you got 0 from recv,
you should get RESET. If you try to send the data after you got RESET,
you'll get EPIPE or SIGPIPE.

So, theoretically, you can see ECONNRESET in recv only if the peer does
shutdown(SHUT_RD) and you try to send some data after this. Which
usually never happens :) More often the peer closes socket unexpectedly
while you are sending many chunks of data and as result you get
SIGPIPE, because your first send triggers RESET, and your second send
triggers SIGPIPE, because you didn't see the RESET.

--
Minds, like parachutes, function best when open
.



Relevant Pages

  • Re: urllib (54, Connection reset by peer) error
    ... It means your client received a TCP segment with the reset bit sent. ... The 'peer' will toss one your way if it determines that a connection ... I have a small Python script to fetch some pages from the internet. ...
    (comp.lang.python)
  • Re: Coping with abnormal network disconections
    ... signaled to you when an incoming FIN is received from remote peer. ... exiting the thread or abort the connection rapidly. ... > interconnected with data paths (not part of the network). ...
    (microsoft.public.win32.programmer.networks)
  • New to SBS 2003 and really struggling
    ... SBS 2003 having always had Peer to Peer networks. ... I decided to upgrade our peer to peer network to SBS 2003 with I have to say ... broadband connection via an ADSL modem. ... Ethernet to the server. ...
    (microsoft.public.windows.server.sbs)
  • Re: vpn redundancy PIX and 3000 series
    ... 501s is dominating the 3002hw clients for our branches, ... So I was just reading up some more and found a setup for pix to pix ... >>they can vpn into a pix525 firewall, and if the internet connection the ... > at least at the naive level, provided the new peer is reached through ...
    (comp.dcom.sys.cisco)
  • Re: Read Fail -104 -Connection reset by peer.
    ... Read Fail -104 -Connection reset by peer. ... It should not be request per connection, as it will create too man ...
    (comp.unix.programmer)