0 pts.
 Check Connection established on a TCP port from a program?
Is there any way to get the status of a TCP port within a program? We need to monitor a specific port to ensure that a communications link is established, and then send a page to the analyst on call when the communications link goes down. I can view the information with NETSTAT 3 (WRKTCPSTS *CNN), but I need to create a never ending batch process to do the monitoring. Any help would be appreciated.

Software/Hardware used:
ASKED: September 29, 2005  12:23 PM
UPDATED: November 14, 2009  1:00 PM

Answer Wiki:
You should be able to do that using WMI. Have a look at the Win32_SystemNetworkConnections and Win32_NetworkConnection classes.
Last Wiki Answer Submitted:  September 29, 2005  3:58 pm  by  Amigus   0 pts.
All Answer Wiki Contributors:  Amigus   0 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

You might try looking at API QTocRtvNetCnnDta (Retrieve Network Connection Data)in IBM’s Information Centre

 0 pts.

 

WhatsUp Gold is a good inexpensive application that you can purchase that will handle this. Its good in a Windows environment although you can measure any platform with it via SNMP.

Nagios is a good Unix Base application. I believe it is freeware.

 0 pts.

 

ttrish is right.

Just about the only way you can recreate the functionality of netstat option 3 is by calling the API of QTocRtvNetCnnDta….however, Im not that strong with API programming….

ttrish, can u send us a sample source code that will call this API?

 10 pts.

 

What do you mean by “monitoring”? If there’s a program communicating through the port, it knows if it’s communicating or not. What are you expecting something outside the program to do that the program can’t do easier?

And what do you mean by “communications link”? The internet? Or do you have a modem/point-to-point connection or similar?

Please provide some info on what the process is. It’s far too vague so far.

The QTocRtvNetCnnDta API might be appropriate, but there’s no way to know from the info so far. And it’s not a trivial API, especially if you don’t already know sockets programming to help interpret the results. Connections come and go all the time. You don’t want to be alerting an admin every 20 minutes for no good reason.

Tom

 107,935 pts.