ECONNREFUSED in recvfrom ?

Davide Rossetti (rossetti@apemaia.roma1.infn.it)
Mon, 12 Oct 1998 15:25:34 +0200 (MET DST)


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.

tried strace on it and it's strange that on the faulty recvfrom, strace is
unable to decode the sockaddr_in pointer.

this is the rilevant strace log:

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
...
bind(3, {sin_family=AF_INET, sin_port=htons(10000),
sin_addr=inet_addr("0.0.0.0")}, 16) = 0
...
setsockopt(3, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0
...
fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
...
fcntl(3, F_SETFL, O_RDWR) = 0
...
recvfrom(3, "ciccio bello e lillino\0", 59999, 0, {sin_family=AF_INET,
sin_port=htons(10000), sin_addr=inet_addr("141.108.2.54")}, [16]) = 23
...
sendto(3, "ciccio bello e lillino\0", 23, 0, {sin_family=AF_INET,
sin_port=htons
(10000), sin_addr=inet_addr("141.108.2.54")}, 16) = 23
...
recvfrom(3, 0xbfff0950, 59999, 0, 0x40128fec, 0xbfff08b8) = -1
ECONNREFUSED (Connection refused)

I admit that in my deep C++ encapsulation, I could have done an
error everywhere, but it's so subtle (for me) that a little help would be
decisive.

thanks. regards.

+------------------------------------------------------------------+
|Rossetti Davide INFN - Sezione Roma I - gruppo V, prog. APEmille|
| web : http://apemaia.roma1.infn.it/~rossetti |
| """"" E-mail : davide.rossetti@roma1.infn.it |
| |o o| phone : (+39)-6-49914412 |
|--o00O-O00o-- fax : (+39)-6-4957697 |
| address: Dipartimento di Fisica (V.E.) |
| Universita' di Roma "La Sapienza" |
| P.le Aldo Moro,5 I - 00185 Roma - Italy|
| pgp pub. key: finger rossetti@apemaia.roma1.infn.it |
| |
|"Most people think about twice a year. I got famous by thinking |
| once a week." - George B. Shaw (see Appendix A) |
+------------------------------------------------------------------+

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