Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find a list of sockets held by a process in windows?

I have a .Net application that maintains a socket pool to reuse them. It is suspected that it might be holding too many of those sockets without releasing them. Is there a way to find the number of socket handles the application is holding to in Windows?

like image 755
Sriram Subramanian Avatar asked Jan 17 '12 21:01

Sriram Subramanian


People also ask

How do you check socket is connected or not Windows?

If you need to determine the current state of the connection, make a nonblocking, zero-byte Send call. If the call returns successfully or throws a WAEWOULDBLOCK error code (10035), then the socket is still connected; otherwise, the socket is no longer connected.


2 Answers

Type netstat -a -o -n -b from an elevated (admin) command prompt.

-b is to display the executable involved in creating each connection or listening port. See netstat --help for a list of all options.

like image 130
selbie Avatar answered Sep 27 '22 18:09

selbie


I like TCPView from SysInternals: http://technet.microsoft.com/en-us/sysinternals/bb897437 Good for lots of other things too, but to check your own process out, just find it in the list and look at the sockets it has open, addresses they are bound to, etc. You can also watch the dynamic pattern of your processes socket usage.

like image 42
PhysicalEd Avatar answered Sep 27 '22 18:09

PhysicalEd