有没有一种方法可以从Windows命令行检查特定端口的状态?我知道我可以使用netstat来检查所有端口,但netstat很慢,而查看特定的端口可能不是。


当前回答

我使用:

netstat –aon | find "<port number>"

其中o表示进程ID。 现在你可以对进程ID做任何事情。 要终止进程,例如,使用:

taskkill /F /pid <process ID>

其他回答

这对你有帮助

netstat -atn | grep <port no>          # For tcp
netstat -aun | grep <port no>           # For udp
netstat -atun | grep <port no>          # For both

该命令将显示所有端口及其目的地址:

netstat -f 

Windows 8用户:打开命令提示符,输入netstat -an | find "your port number",输入。

如果回复是LISTENING,那么端口正在使用中,否则它是空闲的。

这是一个简单的解决方案的港口寻找…

在cmd:

netstat -na | find "8080"

在bash中:

netstat -na | grep "8080"

PowerShell:

netstat -na | Select-String "8080"

它会给你一个特定IP上所有活动的套接字:

netstat -an | find "172.20.1.166"