36

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?

Sriram Subramanian
  • 2,623
  • 5
  • 32
  • 35
  • Related: [How can I enumerate sockets on a given windows process?](http://stackoverflow.com/q/1337392/95735) – Piotr Dobrogost May 05 '12 at 14:19
  • In case someone else comes across this question, I tested some software called "SocketSniff at http://www.nirsoft.net/utils/socket_sniffer.html. Not only does it show the sockets, but it also shows the content - worked well, even on 64 bit windows. [Please note: use at own risk; take precautions before running anything downloaded for free on the internet; read the disclaimer on the page etc.] – Robbie Nov 21 '13 at 05:53

2 Answers2

58

Try netstat

Type the type the following from an elevated (admin) command prompt:

Windows: netstat -a -o -n -b

Linux: netstat -4 -6 -a -n -p

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

On Linux, -p is the equivalent. Type man netstat for more information.

Linux

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
selbie
  • 100,020
  • 15
  • 103
  • 173
18

Try tcpview.exe

I like TCPView from SysInternals.

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.

StackzOfZtuff
  • 2,534
  • 1
  • 28
  • 25
PhysicalEd
  • 784
  • 7
  • 10