Re: [PATCH] rsocket: Return ECONNRESET when socket in recv is disconnected

Jason Gunthorpe
2014-10-08T23:28:27Z

On Wed, Oct 08, 2014 at 03:19:33PM -0700, sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org wrote:
> The following behavior difference was reported between rsockets and
> sockets:
>
> when remote end is suddenly closed, recv() waiting on it receives
> tcp/ip => ECONNRESET error
> rsockets => 0 value

That isn't the whole story though - you only get ECONNRESET in some
cases, and it is OS dependent.

stackoverflow suggets:

http://stackoverflow.com/questions/2974021/what-does-econnreset-mean-in-the-context-of-an-af-local-socket

Which looks reasonable to me and matches my experience with socket
programming on Linux. The Steven's book might have some authoritative
clarifications on the subject as well.

It certainly is not correct to unconditionally return ECONNRESET for
reads on far-end-closed sockets, they should typically return 0.

Jason