Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using VB6 how to detect Close_wait and Fin_Wait programatically

Posted on 2016-08-24
3
Medium Priority
?
74 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Creating an OSPF network that automatically (dynamically) reroutes network traffic over other connections to prevent network downtime.
Configuring network clients can be a chore, especially if there are a large number of them or a lot of itinerant users.  DHCP dynamically manages this process, much to the relief of users and administrators alike!
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…
Suggested Courses

722 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