In my specific case, I had a server running on the local host that was listening on the UDP socket associated with a particular port. He also had a second UDP socket connected to the same port (this makes sense in context), used only to send responses to packets received on the first socket.
Clients also working on the local host will create a temporary socket, send a packet to the server, wait for a response, and then close their socket. The client side timeout was very short (for reasons related to the application), with a retry if the time of the initial attempt expired.
Sometimes it happens that the client sends a packet to the server, waiting for a response to be sent, and closes its socket. Then the server will receive (on the listening socket) a packet from the client and send a response (on the sending socket). However, Windows "helpfully" sends an ICMP response stating that there are no more listening sockets on the target port. It is important to note that this packet is ultimately delivered to the listening socket, and not to the sending socket (since they both use the same port). The next time you read from the listening socket on the WSAECONNRESET server, a WSAECONNRESET error indicates that the previous packet that it sent (which was actually sent from another socket) was not delivered.
In my case, the fix was to simply ignore WSAECONNRESET errors on the listening socket. The listening socket continued to accept other packets successfully after such errors occurred, and the sending socket continued to successfully send packets after the packet was not delivered.
source share