why linux reuse ‘time_wait’ port?

As I know, tcp port in ‘time_wait’ stat cann’t be used. However, in my experiment, server reuses the ‘time_wait’ port? Why? Firstly, in client machine, type command ehco 40000 40001 > /proc/sys/net/ipv4/ip_local_port_range. So, the maximum number of TCP ports is 2. server code while (1) { int len = sizeof(struct sockaddr); fd = accept(sfd, &remote, … Read more

Avoid TIME_WAIT connections [duplicate]

This question already has answers here: How to reduce number of sockets in TIME_WAIT? (2 answers) Closed 9 years ago. When I use netstat command it shows.. tcp 0 0 localhost:18056 localhost:mysql TIME_WAIT tcp 0 0 localhost:16683 localhost:mysql TIME_WAIT tcp 0 0 localhost:16701 localhost:mysql TIME_WAIT tcp 0 0 localhost:16888 localhost:mysql TIME_WAIT tcp 0 0 localhost:16832 … Read more