Steps to check whether a process had utilised a port before your application does with windows built in facilities

As a systems analyst, it is inevitable for me to go to windows based computers to check out the applications that I am taking care of. Most of my applications listen to commands via TCP/IP ports in order to do work.

Whenever a user reports that one of such applications is failing on their machine, the first thing that I will check out is whether that application is able to reserve the port that it is supposed to listen to.

Although there are Sysinternal suite of diagnostic tools for me to use, there are client machines does not allow foreign executables to execute on them.

This post details the steps that I take to check out whether there is a port binding issue in the event that my application fail to run in windows based machines.

  1. Start command prompt. Inside command prompt, type 'netstat –aon'
  2. Look for the number which my application listen to, after :, and look at the last column for the pid.
  3. Open up task manager.
  4. In task manager, go to the processes tab. Look at the PID column. If the column is not available, go to view -> Select Column... and check on the PID option.
  5. Match the pid to the one that u get from step 2) and look at the process name.

If the process name shown is not my application executable, it will mean that my application had failed to grab hold of the port for it to do work, and I can take steps to bring it up again.

If the process name shown is indeed my application executable, I can continue with the performing other debug procedures for that application.

About Clivant

Clivant a.k.a Chai Heng enjoys composing software and building systems to serve people. He owns and hopes that whatever he had written and built so far had benefited people. All views expressed belongs to him and are not representative of the company that he works/worked for.