Port is still be used after tcp connection is closed

by qqyypCaq
GNU/Linux ◆ xterm-256color ◆ zsh 5550 views

According to tcp state transition diagram, the acitive closer with stay in TIME_WAIT state for 2 MSL(max segment lifetime) before back to CLOSED state while the passive closer neednot. In this example, we use nc to act as counterpart of tcp connection. The server act as the active closer, who will wait 2 MSL time. the netstat command can help use insight the tcp state of certain port. When TCP connection is built, both side went into ESTABLISHED state. When enter Ctrl-C in client side terminal, both side stop the connection. The server, which port is 6666, acting as passive closer, exit immediately. watch command can enable us to scout TCP status continously.