Monitor socket dispose

  • Thread starter Thread starter Gianmaria Iaculo - NVENTA
  • Start date Start date
G

Gianmaria Iaculo - NVENTA

Hi,
anyone knows or have a software to count the number of open sockets on a
machine? I'm developng a socket server and need to monitor the corret
dispose of unused sockets.

regards
Gianmaria
 
Gianmaria Iaculo - NVENTA said:
Hi,
anyone knows or have a software to count the number of open sockets on a
machine? I'm developng a socket server and need to monitor the corret
dispose of unused sockets.

Do you need to do this in code?

If you just need to check the open sockets on a machine, "Netstat.Exe" is
the way to go. You can run it from the command line.

I typically run, "netstat -a -o -n". This gives me a list of all open
sockets, doesn't to reverse dns on the endpoints (which takes forever) and
tells me the owning process for each socket (which I can then look up in
Task Manager by adding in the PID column). I'll often pipe this through find
to get a count: netstat -a -o -n | find /c "5222"

To do this in code, I believe you need to use WMI.
 
Chris Mullins said:
[...]
I typically run, "netstat -a -o -n". This gives me a list of all open
sockets, doesn't to reverse dns on the endpoints (which takes forever) and
tells me the owning process for each socket (which I can then look up in
Task Manager by adding in the PID column). I'll often pipe this through
find to get a count: netstat -a -o -n | find /c "5222"

To do this in code, I believe you need to use WMI.

I don't know enough about WMI to speak for whether it's a better solution
than the "old school" way (it may well be), but...

Another way to get information like this is to use the iphlpapi.dll library.
For example, GetTcpTable and GetUdpTable.
http://msdn2.microsoft.com/en-us/library/aa366071.aspx
P/invoke or similar required, of course. It's not a .NET API.

Pete
 
Process Explorer from sysinterrnals.com will give you a list of open socket
for a program and show when new ones open and close. Works pretty well.

Regards,
John
 
Thank you al Guys.. i dont want code nothing.. i just was looking for an
utility like the one john signaled.
I will try to download immediatly.

txs again
Gianmaria
ITALY

John J. Hughes II said:
Process Explorer from sysinterrnals.com will give you a list of open
socket for a program and show when new ones open and close. Works pretty
well.

Regards,
John
 
Back
Top