Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Obtain network port status?

Status
Not open for further replies.

darkman0101

Technical User
Oct 10, 2000
51
NZ
I am trying to obtain the status (eg listening or established) for a tcp port. When a certain service starts it listens on port x. I want to monitor this port to know when a remote machine connects to it.

I can pipe 'netstat -a -n' to a disk file and read each line for this local port and read the status, but this will need to be done on a timer event (thereby using some cpu time) and will result on a disk read/write each time.
I want to avoid this if possible.

Is there something in the APIs that will do a netstat like function and allow me to watch this port. Or do I somehow need to attach a socket to this port and watch for data (I may be talking "out of my league" on this last idea as I know very little on networking)

Any help would be appreciated

Jas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top