Jonas Hei
2006-06-21 13:43:05 UTC
Our application does UDP communications using the Socket class in
System.Net.Sockets.
The Socket.EndReceiveFrom() often throws a SocketException (ErrorCode:
10054, WSAECONNRESET, "An existing connection was forcibly closed by the
remote host").
This seems to be a common problem affecting a lot of people and it
appears that this happens due to 'ICMP Port unreachable' responses to
the UDP messages already sent out. KB263823
(http://support.microsoft.com/kb/263823/en-us) explains the problem.
Looking at the above KB I expect to get SocketExceptions with
WSAECONNRESET during Socket.EndReceiveFrom(). And they do happen often.
But sometimes I also get same exception during
Socket.BeginReceiveFrom(). Why?
What is the best way to fix this problem?
Should we be using Socket.IOControl() to set SIO_UDP_CONNRESET to false?
(Our application runs on Windows Server 2003)
Or should we be catching SocketExceptions and ignoring the WSAECONNRESET
errors?
System.Net.Sockets.
The Socket.EndReceiveFrom() often throws a SocketException (ErrorCode:
10054, WSAECONNRESET, "An existing connection was forcibly closed by the
remote host").
This seems to be a common problem affecting a lot of people and it
appears that this happens due to 'ICMP Port unreachable' responses to
the UDP messages already sent out. KB263823
(http://support.microsoft.com/kb/263823/en-us) explains the problem.
Looking at the above KB I expect to get SocketExceptions with
WSAECONNRESET during Socket.EndReceiveFrom(). And they do happen often.
But sometimes I also get same exception during
Socket.BeginReceiveFrom(). Why?
What is the best way to fix this problem?
Should we be using Socket.IOControl() to set SIO_UDP_CONNRESET to false?
(Our application runs on Windows Server 2003)
Or should we be catching SocketExceptions and ignoring the WSAECONNRESET
errors?