Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket error 10052 on UDP socket

Tags:

sockets

We have a .NET 2.0 desktop application which sends and receives network packets over UDP.

Several users have reported an occasional socket error 10052 which happens when the code calls socket.BeginReceiveFrom on a the UDP socket.

What does this mean?

The official MS documentation for socket error 10052 says - quote: "WSAENETRESET (10052) Network dropped connection on reset . The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress. It can also be returned by setsockopt if an attempt is made to set SO_KEEPALIVE on a connection that has already failed."

This just doesn't make much sense for a UDP socket since UDP is a connectionless protocol.

I know that another close error code 10054 in connection with UDP sockets means that an ICMP message "Port Unreachable" was received, and I am wondering if 10052 might map to another ICMP message?

I have googled this for months, read network books, etc. but can't find anything. Please help - what does socket error 10052 on a UDP socket mean?

Thanks in advance

like image 996
Jesper Avatar asked Jun 19 '09 06:06

Jesper


3 Answers

See http://msdn.microsoft.com/en-us/library/ms740120%28v=vs.85%29.aspx, which describes the recvfrom function. It says of WSAENETRESET (which is winsock error 10052):

For a datagram socket, this error indicates that the time to live has expired.

like image 149
spiv Avatar answered Nov 19 '22 00:11

spiv


Be sure that TTL value is high enough, when sending UDP datagrams.

If you are using UdpClient class. Then use the following before sending the datagram:

myUdpClient.Ttl = 255;

Note: 255 is the maximum value for TTL. There is some network problem if that value is not enough.

like image 3
SKi Avatar answered Nov 18 '22 22:11

SKi


WSAE NET RESET suggests that it happens due to a reset of the network interface itself. Your program is sitting there bound to a UDP port, so in a sense it is connected, but to the network interface rather than to a remote peer.

Try starting your program, getting it to the point where this BeginReceiveFrom call is about to be made, then disable your NIC in the Device Manager and re-enable it. Or, with Wi-Fi, drop and reestablish the connection to the WAP. It might even happen by just unplugging the Ethernet cable to your machine, as recent versions of Windows default to killing all sockets connected through that NIC when this happens.

It would explain the rare problem reports from the field. This probably only happens when there is some local networking fault at the hardware level.

like image 2
Warren Young Avatar answered Nov 18 '22 23:11

Warren Young