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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check if TCP Port is open

Status
Not open for further replies.

cspm2003

Programmer
Nov 24, 2004
78
DE
Hi,

I have a problem: I have a script that needs to check if a tcp port is used. if its not used it shall start a program, if the port is used it should do nothing.

The tcp port I want to check is 5555.

I read something about winsock but didnt really get anywhere :S.

I could do it by using the netstat ´command and put the output in a file but thats taking to long as it needs to be done under 300ms (milisecounds).

help is greatly appreciated.

Regards Max
 
it needs to be done under 300ms
I'm afraid scripting is not well suited for that.
 
it has to be done with a script. the script is a generic cluster script, it implements the isAlive and looksAlive function. those check if the program is still running, looksAlive can not take longer then 300ms. I could probably just set looksAlive to TRUE and put the code in the isAlive function, that way it could take longer.

the netstat implementation i tryed took about 20 - 30 secounds, so I gues anything faster then that would be great :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top