Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find application using port

Tags:

c#

netstat

wmi

I have a networking program setup that does a lot of what the nestat program does. I am working now on netstat -o. That command will give me the PID of the program using that socket. I have some idea of where to look. I have been trying to use WMI to get that information but so far I have not found a suitable class.

How can I find the PID or application name that is using a particular socket?

I am using c#

like image 725
Paul Avatar asked Sep 05 '25 06:09

Paul


1 Answers

AFAIK, this information is not exposed anywhere in the BCL or WMI. You'll need to p/Invoke GetExtendedTcpTable to get it.

like image 156
Stephen Cleary Avatar answered Sep 07 '25 19:09

Stephen Cleary