Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.