What port is a given program using? [closed]

2019-01-12 22:22发布

I want to be able to figure out what port a particular program is using. Are there any programs available online or that come with windows that will tell me which processes are using which ports on my computer?

PS - before you downmod this for not being a programming question, I'm looking for the program to test some networking code.

12条回答
Juvenile、少年°
2楼-- · 2019-01-12 22:31

most decent firewall programs should allow you to access this information. I know that Agnitum OutpostPro Firewall does.

查看更多
放荡不羁爱自由
3楼-- · 2019-01-12 22:32

You can use the 'netstat' command for this. There's a description of doing this sort of thing here.

查看更多
祖国的老花朵
4楼-- · 2019-01-12 22:35

If your prefer a GUI interface CurrPorts is free and works with all versions of windows. Shows ports and what process has them open.

查看更多
迷人小祖宗
5楼-- · 2019-01-12 22:37

TCPView can do what you asked for.

查看更多
祖国的老花朵
6楼-- · 2019-01-12 22:40

netstat -b -a lists the ports in use and gives you the executable that's using each one. I believe you need to be in the administrator group to do this, and I don't know what security implications there are on Vista.

I usually add -n as well to make it a little faster, but adding -b can make it quite slow.

Edit: If you need more functionality than netstat provides, vasac suggests that you try TCPView.

查看更多
Emotional °昔
7楼-- · 2019-01-12 22:45

On Vista, you do need elevated privileges to use the -b option with netstat. To get around that, you could run "netstat -ano" which will show all open ports along with the associated process id. You could then use tasklist to lookup which process has the corresponding id.

C:\>netstat -ano

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  ...
  TCP    [::]:49335             [::]:0                 LISTENING       1056
  ...

C:\>tasklist /fi "pid eq 1056"

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
sqlservr.exe                  1056 Services                   0     66,192 K
查看更多
登录 后发表回答