I have a client application, which uses a unmanaged dll for communicating with a server.
All network-related operations are perormed inside the unmanaged dll. After a number of operations with the server, the client is running out of TCP ports. If we check the state of netwotk using 'netstat -an', we get the following result:
...
TCP 192.168.11.55:56048 192.168.10.28:5000 FIN_WAIT_2
TCP 192.168.11.55:56049 192.168.10.28:5000 FIN_WAIT_2
TCP 192.168.11.55:56050 192.168.10.28:5000 FIN_WAIT_2
TCP 192.168.11.55:56051 192.168.10.27:5000 FIN_WAIT_2
TCP 192.168.11.55:56052 192.168.10.28:5000 FIN_WAIT_2
TCP 192.168.11.55:56053 192.168.10.27:5000 FIN_WAIT_2
TCP 192.168.11.55:56054 192.168.10.27:5000 FIN_WAIT_2
TCP 192.168.11.55:56055 192.168.10.27:5000 FIN_WAIT_2
TCP 192.168.11.55:56056 192.168.10.27:5000 FIN_WAIT_2
TCP 192.168.11.55:56057 192.168.10.28:5000 FIN_WAIT_2
TCP 192.168.11.55:56058 192.168.10.27:5000 FIN_WAIT_2
TCP 192.168.11.55:56059 192.168.10.28:5000 FIN_WAIT_2
TCP 192.168.11.55:56060 192.168.10.27:5000 FIN_WAIT_2
...
The ports are released only after the client is closed.
If I run the VS project in Debug Mode, it never runs out the ports. But, while running in Release mode, it is happening.
And I don't have access neither to server nor client source.
How to release or kill those ports which are in FIN_WAIT_2 state?