Solved

Using VB6 how to detect Close_wait and Fin_Wait programatically

Posted on 2016-08-24
3
20 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

706 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now