Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

OS: Windows Server 2003

Is there any tool that can test if a certain port is available for my program to listen to? Thanks.

share|improve this question
up vote 2 down vote accepted

For windows: netstat will show you existing port numbers - just pick one that's not used.

To see what ports are listening on a machine - nmap the machine.

To verify that it's your program getting the input properly - telnet to that port and then type stuff and see if your program gets it.

share|improve this answer

Might want to first become aware of possible port conflicts by checking out a list of common ports uses:

You can see what ports are being listened too at the time by using netstat as @robert has said. :

You can test if a port is accessable form the outside by using one of several online port scanners:

And finally, check that the port is not being blocked:

share|improve this answer

I think the general idea is usually that your program should try to bind to the port with a function and then you would check the return value to make sure the bind was successful. If unsuccessful, you error out. This is coming from a *nix perspective, but I was under the impression this is pretty universal.

The reason I feel that it is universal is that ideally the check port and bind to port would need to be atomic. This, in this usage means that no other program has a chance of using the port between when check is done and the port is allocated. In case like using something like netstat first, it is possible between your check and trying to use the port something else will have used it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.