Detecting network connection (operational status)


G

Guest

Hi!

I have question regarding detecting net connection (up, down,...). I know
there has been already a lot of this (probably) written.
I just need to detect if my WinCE 5.0 device has a network (LAN) connection
or not. I’m also trying with OpenNETCF, but nothing really does the job.
I’m using static IP etc.
I’ve got as far as pinging remote server and collecting information from all
adapters on the device (LAN, Bluetooth, IR,…).
Question is what class to use for testing if Ethernet adapter is UP or DOWN
and is there any event to test if state of adapter has changed (up->down,
down->up). Maybe some kind of operational status of the device?

And can you please attach a little example a long?

Thanks,
Smiljan
 
Ad

Advertisements

P

Paul G. Tobey [eMVP]

The problem is that up or down has no definition. Some adapters will
indicate if they have media connection (the Ethernet cable is plugged in),
but having the Ethernet cable plugged in doesn't tell you whether it's
working or not. Ping or otherwise contact a remote server, preferably the
one that you want to talk to. If that works, obviously there's some network
path to get there. If not, there isn't.

Paul T.
 
G

Guest

Thanks for the answer.
So, it is probably best to create a timer that periodicaly pings destination
server for connection. What do you think?

Smiljan
 
Ad

Advertisements

P

Paul G. Tobey [eMVP]

It depends on what you're trying to accomplish. You haven't really told us
*what* you're trying to do, other than figure out if the network is up. The
most-effective way of doing that is to use it for whatever network stuff you
need to do, remembering that it might go down at any time (and that your
code should handle that gracefully). You don't need to ping all the time,
in that case; you'll be told forcefully, probably via an IoException, that
things have gone bad, if you need to know. I guess that you could then go
into a state where you ping every so often to detect it coming back up. If
you're just trying to build a utility that shows the network state, I'd just
show the connected state, not trying to indicate whether it's really fully
operational or not.

Paul T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top