Java 如何关闭 Windows 7 中打开的端口?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3992452/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 08:04:04  来源:igfitidea点击:

How do i close an opened port in Windows 7?

javawindows

提问by Alejandro

when i try to start my java based server there is a message that says the port is already in use... And all my java web servers are stopped... So if anyone can help me i will appreciate it...

当我尝试启动基于 Java 的服务器时,有一条消息说该端口已在使用中......我所有的 Java Web 服务器都已停止......所以如果有人能帮助我,我将不胜感激......

采纳答案by Jim Brissom

If there is really still a process that has the port open, you can easily check for that (and close the process) via TCPView. It might be that the port is just lingering (for example due to not being shutdown properly), in which case you'd have to wait for the socket to close and check that the code is clear with regard to that.

如果确实仍有一个进程打开了端口,您可以通过TCPView轻松检查(并关闭进程)。可能是该端口只是挥之不去(例如,由于未正确关闭),在这种情况下,您必须等待套接字关闭并检查代码是否清楚。

回答by CrazyDart

A few options... us TCPViewto find the program that has the port open and kill it... reboot... just reset the network connection. Try those.

几个选项...我们TCPView找到打开端口的程序并杀死它...重新启动...只需重置网络连接。试试那些。

回答by Anup

I was trying to establish socket communication between PC(JAVA Server)<-->Android(Client)

on Debugging, popped the problem : Address already in use

instant/feasible resolutioni found out was to:

我试图 在调试时在PCJAVA 服务器)<--> Android客户端)之间建立套接字通信

,但出现了问题:我发现Address already in use

即时/可行的解决方案是:

  • run cmdas adminstrator
  • netstat -abn
  • find the process listening to the port of intrest
  • terminate the process from task manager
  • 管理员身份运行cmd
  • netstat -abn
  • 找到监听端口的进程
  • 任务管理器终止进程


PS : Unlike from an external application mentioned in previous answers, steps in this answer allows you to find out the used ports with the resources already present.

PS:与先前答案中提到的外部应用程序不同,此答案中的步骤允许您找出已使用资源的已使用端口。