Using VB6 how to detect Close_wait and Fin_Wait programatically
Posted on 2016-08-24
The following code I am using to detect if a local TCP port is available or reserved.
On Error Resume Next
Winsock1.LocalPort = "123"
If Err.Number = 10048 Then (the port is reserved)
The Err.Number is zero if the requested local TCP port is Close_wait or Fin_Wait.
And when trying to comunicate it is not allowing until the TCP port is released.
In other words, the error handling is not a suitable way to evaluate the availablity of a port.
Is there a better way to check the availability of a port, (detect Close_wait, Fin_Wait, and port in use)?