The TIME_WAIT TCP port state
Indicates that both endpoints of a connection have closed it, and that the local end is keeping the local port in TIME_WAIT state. The system is waiting for any remaining packets to expire before closing the port. This state only lasts 2*MSL seconds where MSL is the maximum segment lifetime, typically 60 or 120 seconds.
The TIME_WAIT state is often erroneously regarded as a performance problem. It isn't, except for the length of netstat
displays. However it can be avoided altogether by being the end which receives the first FIN. In practice this means the client should close the connection before the server, so that the ports in TIME_WAIT state accumulate at the client, where they are few, rather than at the server, where they are very many.