This is a mirror of official site: http://jasper-net.blogspot.com/

.NET Network Monitor

| Sunday, July 17, 2011
Introduction

I need to monitor Network status in my project.To check the cable has bad contact or not and to check network is enable or not.So I develop a simple tool to test.
Background

This sample is using WMI to get information in .NET.
Using the Code 

I use a singleton to manager all network information. Now, call this code to initialize and monitor:

NetworkManager.Instance.StartMonitor();

And foreach NetworkManager.Instance.Informations.Values to get information:

foreach(NetworkInfo info in NetworkManager.Instance.Informations.Values)
{
    Console.WriteLine("Device Name:" + info.DeviceName);
    Console.WriteLine("Adapter Type:" + info.AdapterType);
    Console.WriteLine("MAC Address:" + info.MacAddress);
    Console.WriteLine("Connection Name:" + info.ConnectionID);
    Console.WriteLine("IP Address:" + info.IP);
    Console.WriteLine("Connection Status:" + info.Status.ToString());
}

At last call this to destory:

NetworkManager.Instance.Destory();

Abort the Code

public enum NetConnectionStatus
{
    Disconnected = 0,
    Connecting = 1,
    Connected = 2,
    Disconnecting = 3,
    HardwareNotPresent = 4,
    HardwareDisabled = 5,
    HardwareMalfunction = 6,
    MediaDisconnected = 7,
    Authenticating = 8,
    AuthenticationSucceeded = 9,
    AuthenticationFailed = 10,
    InvalidAddress = 11,
    CredentialsRequired = 12
}

First, this enum named NetConnectionStatus that is reference from the property NetConnectionStatus in Win32NetworkAdapter class.


Read more: Codeproject
QR: _NET_Network_Monitor.aspx

Posted via email from Jasper-net

7 comments:

Anonymous said...

Aw, this was a really nice post. Finding the time and actual effort to generate a great article… but what can I say… I put
things off a lot and never manage to get
nearly anything done.

Feel free to visit my weblog - exercises to improve vertical leap

Anonymous said...

I'm not certain the place you're getting your info,
but good topic. I must spend some time learning more or figuring
out more. Thank you for wonderful info I was looking for this info for my mission.


Feel free to surf to my webpage exercises for vertical

Anonymous said...

Hmm it seems like your blog ate my first comment (it was super long) so I guess I'll just sum it up what I submitted and say, I'm thoroughly enjoying your blog.
I too am an aspiring blog blogger but I'm still new to everything. Do you have any recommendations for first-time blog writers? I'd definitely appreciate it.



Also visit my web-site :: workouts to Improve vertical

Anonymous said...

For latest information you have to go to see world-wide-web and on web I found this site as
a finest web page for most up-to-date updates.

Also visit my blog post: workouts to jump higher

Anonymous said...

This website was... how do I say it? Relevant!! Finally I've found something that helped me. Kudos!

Feel free to visit my blog post; zadavator.spbal.ru

Anonymous said...

What's Taking place i'm new to this, I stumbled upon this I've found It positively useful and it has helped me out loads. I hope to give a contribution & help other users like its aided me. Great job.

Stop by my web-site; exercises to improve vertical

Anonymous said...

Hello everyone, it's my first visit at this site, and article is actually fruitful for me, keep up posting these types of articles.

my homepage - exercises to improve vertical jump