For my suggestion, please read the last section: “When to use SO_LINGER with timeout 0”. Before we come to that a little lecture about: Normal TCP termination TIME_WAIT FIN, ACK and RST Normal TCP termination The normal TCP termination sequence looks like this (simplified): We have two peers: A and B A calls close() A sends FIN to B A goes into FIN_WAIT_1 state B receives FIN B sends ACK to A B go