Solved

Using VB6 how to detect Close_wait and Fin_Wait programatically

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

16 Experts available now in Live!

Get 1:1 Help Now