473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Monitor socket dispose

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
Jan 3 '07 #1
4 4695
"Gianmaria Iaculo - NVENTA" <gianmaria.iATrpcnetPUNTO.itwrote
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, MCSD.NET, MCPD:Enterprise, MVP C#
http://www.coversant.net/blogs/cmullins
Jan 3 '07 #2
"Chris Mullins [MVP]" <cm******@yahoo.comwrote in message
news:uF*************@TK2MSFTNGP04.phx.gbl...
[...]
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
Jan 3 '07 #3
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

"Chris Mullins [MVP]" <cm******@yahoo.comwrote in message
news:uF*************@TK2MSFTNGP04.phx.gbl...
"Gianmaria Iaculo - NVENTA" <gianmaria.iATrpcnetPUNTO.itwrote
>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, MCSD.NET, MCPD:Enterprise, MVP C#
http://www.coversant.net/blogs/cmullins

Jan 4 '07 #4
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" <in*****@nowhere.comha scritto nel messaggio
news:%2****************@TK2MSFTNGP04.phx.gbl...
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

"Chris Mullins [MVP]" <cm******@yahoo.comwrote in message
news:uF*************@TK2MSFTNGP04.phx.gbl...
>"Gianmaria Iaculo - NVENTA" <gianmaria.iATrpcnetPUNTO.itwrote
>>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, MCSD.NET, MCPD:Enterprise, MVP C#
http://www.coversant.net/blogs/cmullins


Jan 4 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Danny Jensen | last post by:
I need to test if certain processes on a unix box were running. I wanted to use whatsup gold to do the testing. First I needed to go to the whatsup configure>monitors & services menu to add this...
1
by: J. Dudgeon | last post by:
Hello, I've written a server that acts as a proxy between the PC and the mainframe worlds. This server service is writting in C# w/.NET 1.1. The service is TCP/IP based and makes heavy use of...
4
by: DreJoh | last post by:
I've read many articles on the subject and the majority of them give the same solution that's in article 821625 on the MSDN website. I'm using the following code and when a the client disconnects...
2
by: Bryan Mayland | last post by:
I've got a problem with a System.Net.Socket that is failing on connect. Each time I attempt a connection, 3 handles are allocated, and when the connect fails 2 handles are freed. If left retrying...
1
by: Dan Kelley | last post by:
I have 2 projects - 1 Winform project that sends Udp messages using the UdpClient class when a button is clicked, and a Console application that listens for these Udp messages. If I try to use...
2
by: Dan Holmes | last post by:
The following is the start of an application that will eventually run as a service. It listens on port 23 and emulates VT100. I would like some feedback on the network stream reading and writing....
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
0
by: FragMagnet | last post by:
Hi all, I've run into a bit of a snag while dealing with asynchronous sockets. What I'm trying to do is set a timeout for which the server will listen for a connection from a client, at which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.