0

I am working on a project where I have to find the process id . I know local address , protocol , foreign address and state. I don't know process name.

I don't want to use netstat -ano or any other third party software.

Is there any way to do that in C# using any library ?

Akash Kumar
  • 307
  • 1
  • 4
  • 9
  • Does this answer your question? [How do I get process name of an open port in C#?](https://stackoverflow.com/questions/1675077/how-do-i-get-process-name-of-an-open-port-in-c) – oleksa Sep 06 '21 at 09:34
  • No, As I have already mentioned I don't want to use netstat command. In most of the answers they have used netstat -ano . – Akash Kumar Sep 06 '21 at 09:45
  • 1
    the accepted answer has no `netstat` usage. Please check the source code. The API `GetExtendedTcpTable` call is used. [Here is](https://stackoverflow.com/questions/577433/which-pid-listens-on-a-given-port-in-c-sharp) another answer – oleksa Sep 06 '21 at 09:55
  • Just tried the solution it is working but how can I pass address, for example I want to get pid of 127.0.0.1:8008 , where should I pass this address ? – Akash Kumar Sep 06 '21 at 10:19
  • you have the port number 8080 so try to iterate over the `GetExtendedTcpTable` result and check is there 8080 port in the list – oleksa Sep 06 '21 at 10:53

0 Answers0