Rappel sur TCP/IP et TIME-WAIT : Une connexion TCP/IP se fait toujours d’un port source vers un port destination, donc la connexion vers le port destination d’un serveur initie aussi un port source sur le client, choisi aléatoirement. Une fois que la connexion est fermée, le couple « port source- port destination » reste indisponible pendant TIME-WAIT pour éviter les problème où un paquet resté bloqué sur le réseau viendrait perturber la connexion suivante.
Cependant quand une machine donnée ouvre un très grand nombre de connexion vers le même port serveur, qu’elle referme très vite, elle peut finir par consommer tous les ports sources qui lui sont disponibles.
Ce problème est particulièrement marqué sous Windows car la plage utilisable par défaut pour ces ports sources est assez restreinte. Une fois que tous les ports sources possibles sont utilisés et en TIME-WAIT, il faut attendre avant d’ouvrir une nouvelle connexion.
Ou augmenter la place utilisable comme décrit ci-dessous.

Please explain the TIME_WAIT state.
The reason that the duration of the TIME_WAIT state is 2*MSL is that the maximum amount of time a packet can wander around a network is assumed to be MSL seconds. The factor of 2 is for the round-trip. The recommended value for MSL is 120 seconds, but Berkeley-derived implementations normally use 30 seconds instead.
one should not avoid the TIME_WAIT state by setting the SO_LINGER option to send an RST instead of the normal TCP connection termination (FIN/ACK/FIN/ACK).
The end that sends the first FIN goes into the TIME_WAIT state, because that is the end that sends the final ACK.

Gsoap : Tuning TCP/IP TIME_WAIT for systems with high connection rates
Set the soap.accept_flags |= SO_LINGER before calling soap_accept(). This works on most systems, but zapping the TIME_WAIT state is not always encouraged!
If that does not work, then reduce the operating system setting for TIME_WAIT substantially to the operating system minimum of 15 or 30 seconds (depending on OS).
1. For Windows: Use regedit and create a REG_DWORD named TcpTimedWaitDelay under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TcpIp\Parameters
Set it to a decimal value of 30 which is for 30 seconds – the minimum.
2. For AIX: To see the current TCP_TIMEWAIT value, run the following command:
/usr/sbin/no a | grep tcp_timewait
To set the TCP_TIMEWAIT values to 15 seconds, run the following command:
/usr/sbin/no o tcp_timewait =1
The tcp_timewait option is used to configure how long connections are kept in the timewait state. It is given in 15-second intervals, and the default is 1.
3. For Linux: Set the timeout_timewait paramater using the following command:
/sbin/sysctl -w net.ipv4.vs.timeout_timewait=30
This will set TME_WAIT for 30 seconds.
4. For Solaris: Set the tcp_time_wait_interval to 30000 milliseconds as follows:
/usr/sbin/ndd -set /dev/tcp tcp_time_wait_interval 30000

TCP TIME_WAIT – what is it?

The TIME-WAIT state in TCP and Its Effect on Busy Servers
TCP requires that the endpoint that closes a connection blocks further connections on the same host/port pair until there are no packets from that connection remaining in the network. Under HTTP, this host is usually the server. […]
If the number of clients continues to increase, the only way to keep server TIME-WAIT memory requirements constant is to move the TIME-WAIT TCBs to clients. Aggregating more requests per connection merely reduces the growth of the memory load with respect to increasing client load; moving the load to clients distributes server memory load to the cause of that load.

msdn WS 2003 : TCP TIME-WAIT Delay
– TcpTimedWaitDelay registry value under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
– MaxUserPorts registry value, also found under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

Dynamic Client Ports in Windows Server 2008 and Windows Vista the dynamic port range is 49152-65535, for both TCP and UDP. – We made this change in order to comply with IANA recommendations
netsh int ipv4 show dynamicport tcp
netsh int ipv4 set dynamicport tcp start=10000 num=1000
MSFT support : The default dynamic port range for TCP/IP has changed in Windows Vista and in Windows Server 2008