Solved

Using VB6 how to detect Close_wait and Fin_Wait programatically

Posted on 2016-08-24
3
35 Views
Last Modified: 2016-09-03
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
Comment
Question by:saljas
  • 2
3 Comments
 
LVL 28

Expert Comment

by:Bill Bach
ID: 41769821
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
 

Accepted Solution

by:
saljas earned 0 total points
ID: 41773451
0
 

Author Closing Comment

by:saljas
ID: 41782782
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question