Re: ECONNREFUSED in recvfrom ?

David Luyer (luyer@ucs.uwa.edu.au)
Tue, 13 Oct 1998 13:35:29 +0800


Chris Wedgwood wrote:
> On Mon, Oct 12, 1998 at 03:25:34PM +0200, Davide Rossetti wrote:
>
> > hi all,
> > i'm stuck with a strange (for me) behaviour of recvfrom with UDP sockets.
> > 1) in the man page, this error code is not documented (ok, they are rather
> > old)
> > 2) the sequence I try is that of a simple echo server (only for test):
> >
> > create AD_DGRAM socket
> > while(select for fd with timeout==-1) {
> > recvfrom(addr, buf, ...);
> > sendto(addr, buf, ...)
> > }
> >
> > the first time ok. I send a packet from another host, recv and send are
> > done. but instead of going back to sleep, it wakes up again and gets an
> > ECONNREFUSED error in recvfrom.
>
> A previous packet you sent on that socket was sent to a host that
> wasn't listening, it sent back and ICMP packet to this effect and it
> gets reported later on...
>
> Have a look at what's going on with tcpdump to see what I mean if my
> explanation isn't clear (alan has a clearly explanation that mine).

>From memory, this was one of the killers for SOCKS5 UDP under Linux - the
socket would die with what they considered an invalid error code and
they would ignore it, close the socket and drop all UDP packets coming back
to that socket. And since it's not a documented error code, the SOCKS5
people just said "it's a Linux bug" and ignored the bug report. It should
either be documented or not be there. Under the libc5 man pages, connection
refused wasn't an option. On the glibc info pages, "recvfrom" doesn't
have documented return codes and "recv" doesn't offer connection refused
as an error code. Either libc5 and glibc documentation is broken or the
kernel is returning an invalid error code - what does POSIX have to say?

David.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/