As mentioned in the previous 4 waves, the end that actively disconnects needs to wait 2 MSLS before finally releasing the connection. If the server hangs and needs to be disconnected, the port will be occupied when the server restarts and rebinds the port, because the port will be released after 2MSL.
1. SO_REUSEADDR parameters
As mentioned above, if the server is disconnected, you must wait 2MSL before rebinding the port. That’s too high a price to pay. In an operating system, ports are not reusable and cannot be bound as long as there are connections occupying the port.
This restriction can be removed by enabling the SO_REUSEADDR socket option
2. Does port reuse only exist in time-wait?
It is not necessary to be in TIME_WAIT to allow port reuse, but in most cases the server that actively closes the connection will be in TIME_WAIT. If SO_REUSEADDR is not set to 1, the server will wait two MSLS before rebinding the original port
3. Why not on the client?
Since the client port uses temporary ports, open the connection and reassign one.