In TIME_WAIT, the bind port will fail after modifying the socket option
In TIME_WAIT, the bind port will fail after modifying the socket option, even if you are using SO_REUSEADDR or SO_REUSEPORT mode
* *
Tcp 0 0 127.0.0.1:81 127.0.0.1:56850 TIME_WAIT
* *
Tcp 0 0 127.0.0.1:81 127.0.0.1:56850 TIME_WAIT
* *
Tcp 0 0 127.0.0.1:81 127.0.0.1:56850 TIME_WAIT
* *
Tcp 0 0 127.0.0.1:81 127.0.0.1:56850 TIME_WAIT
As mentioned above, after the process exits, as long as TIME_WAIT still exists (only disappears after 2MSL), switching the socket option to the bind port will not be successful, such as SO_REUSEADDR and SO_REUSEPORT mode change.
The solution is to set all three variables of tcp_timestamp,tcp_reuse,tcp_recycle to 1 so that TIME_WAIT can be quickly recycled after the process exits.