Connection reset by peer
Jason Orendorff
jason at jorendorff.com
Fri Dec 14 11:52:15 EST 2001
Edward wrote:
> udpCliSock=socket(AF_INET,SOCK_DGRAM)
> data=raw_input('>')
> udpCliSock.sendto(data,ADDR)
> print udpCliSock.getsockname()
> data, addr = udpCliSock.recvfrom(BUFSIZ)
Hmm. It is definitely weird to get ECONNRESET back from a
non-connection-oriented socket.
Well, here's my guess at what's happening.
* Client sends a UDP packet; this gets sent to the server
over the network.
* Server IP layer receives the packet.
* Server IP layer provides a copy of the packet to the server,
since the server is listening on a raw socket.
* Server IP layer then notices that there is no UDP socket
there, on the server, bound to the specified port.
* Server IP layer therefore generates an ICMP "Port Unreachable"
error packet and sends it back to the client.
* Client IP layer receives the error packet and sets a flag on
the udpCliSock saying "hey, you got an error"
* The next time you call udpCliSock.recvfrom(), the error gets
reported.
This is just a guess though.
If the guess is correct, then you can make this work by
creating a udpServerSock on the server; you can set it to
nonblocking, occasionally do udpServerSock.recvfrom() on it,
and discard the results.
Good luck.
--
Jason Orendorff http://www.jorendorff.com/
More information about the Python-list
mailing list