Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 84
  • Last Modified:

Using VB6 how to detect Close_wait and Fin_Wait programatically

The following code I am using to detect if a local TCP port is available or reserved.

    On Error Resume Next
    Winsock1.LocalPort = "123"
    Winsock1.Listen
    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)?

Best Regards,
0
saljas
Asked:
saljas
  • 2
1 Solution
 
Bill BachPresidentCommented:
What about just running the netstat tool and parsing the output? Seems to be no reason to reinvent the wheel in this case.

Of course, if that is unacceptable, then you should be able to find the needed function calls to write your own netstat tool, assuming that visual Basic exposes the right calls.
0
 
saljasAuthor Commented:
0
 
saljasAuthor Commented:
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now