c++ 什么进程正在监听windows中的某个端口 [英] c++ What process is listening on a certain port in windows

查看:196
本文介绍了c++ 什么进程正在监听windows中的某个端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual C++ 中创建了一个程序,并在其中实现了一个 Web 服务.Web 服务设置为侦听端口 80,但如果其他程序已经在使用此端口,Web 服务将无法启动.

I have created a program in visual c++, where i have implemented a web service. The web service is set to listen on port 80, but if another program already is using this port, the web service fail to start up.

所以当webservice无法启动时,我想要一个函数或方法,可以获取当前使用端口80的进程名称.然后我可以向用户打印错误,并询问他关闭进程.

So when the webservice can't start, I would like to have a function or method, which can get the name of the process, that currently uses port 80. Then i can print an error to the user, and ask him to close the process.

推荐答案

GetExtendedTcpTableGetExtendedUdpTable 为您提供网络连接列表.您可以浏览此列表并检查程序是否使用端口 80(它也提供进程 ID).

GetExtendedTcpTable and GetExtendedUdpTable give you a list of network connections. You can walk through this list and check if a program is using port 80 (it provides process IDs as well).

这篇关于c++ 什么进程正在监听windows中的某个端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆