Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How exactly does the TCP stack on windows determine that the connection has been forcibly closed or reset by peer?

I know that TCP on Windows by default tries to retransmit an unacknowledged packet 5 times. What happens if there is still no acknowledgement after 5 attempts? Does it immediately return WSAECONNRESET code on a blocking socket?

Also when we do receive WSAECONNRESET error code, what is the actual state of that TCP connection?

share|improve this question

Connection reset usually means that there was some message from the remote host indicating an error, as opposed to no response which typically generates WSAETIMEDOUT.

For example, the remote host might send an ICMP "Port Unreachable" message, which would indicate that the remote application closed its port.

The TCP connection is closed at that point, although your local socket may still have resources waiting for you to close the socket.

Keep in mind that there can be subtle variations in behavior depending on exactly which version of which operating system is involved.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.