windows 给定的程序使用什么端口?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/105418/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What port is a given program using?
提问by AlexeyMK
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?
我希望能够找出特定程序使用的端口。是否有任何可用的在线程序或 Windows 附带的程序可以告诉我哪些进程正在使用我的计算机上的哪些端口?
PS - before you downmod this for not being a programming question, I'm looking for the program to test some networking code.
PS - 在你因为不是编程问题而降低它之前,我正在寻找该程序来测试一些网络代码。
回答by Graeme Perrow
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.
netstat -b -a
列出正在使用的端口并为您提供使用每个端口的可执行文件。我相信你需要在管理员组中才能做到这一点,我不知道对 Vista 有什么安全影响。
I usually add -n
as well to make it a little faster, but adding -b
can make it quite slow.
我通常-n
也会添加以使其更快一点,但添加-b
会使它变得很慢。
Edit: If you need more functionality than netstat provides, vasac suggeststhat you try TCPView.
回答by Jim Olsen
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.
在 Vista 上,您确实需要提升权限才能在 netstat 中使用 -b 选项。为了解决这个问题,您可以运行“netstat -ano”,它将显示所有打开的端口以及相关的进程 ID。然后,您可以使用 tasklist 查找具有相应 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
回答by Adam Mitz
You may already have Process Explorer (from Sysinternals, now part of Microsoft) installed. If not, go ahead and install it now -- it's just that cool.
您可能已经安装了 Process Explorer(来自 Sysinternals,现在是 Microsoft 的一部分)。如果没有,请立即安装它——它就是那么酷。
In Process Explorer: locate the process in question, right-click and select the TCP/IP tab. It will even show you, for each socket, a stack trace representing the code that opened that socket.
在进程资源管理器中:找到有问题的进程,右键单击并选择 TCP/IP 选项卡。它甚至会为您显示每个套接字的堆栈跟踪,表示打开该套接字的代码。
回答by ctcherry
回答by Steve Baker
"netstat -natp" is what I always use.
“netstat -natp”是我一直使用的。
回答by Adam Rosenfield
Windows comes with the netstat
utility, which should do exactly what you want.
Windows 附带该netstat
实用程序,它应该完全符合您的要求。
回答by Mikezx6r
Windows 8 (and likely 7 + Vista) also provide a view in Resource Monitor. If you select the Network tab, there's a section called 'Listening Ports'. Can sort by port number, and see which process is using it.
Windows 8(可能还有 7 + Vista)也在资源监视器中提供了一个视图。如果您选择“网络”选项卡,则会有一个名为“侦听端口”的部分。可以按端口号排序,并查看哪个进程正在使用它。
回答by CodeRot
At a command line, netstat -a will give you lots o' info.
在命令行中, netstat -a 会给你很多信息。