It appears that once a connection goes to TIME_WAIT state, even if it receives a RST packet from the other side of the connection, the current code won't close the connection associated with this TIME_WAIT state. Let me know if this is a bug or I am wrong. Thanks.