Initial NetworkUp event

Have seen some other threads about this, but nothing in the ‘latest beta’ context. I’m still in a '[em]spike[/em]'ing mode finding out how things work with my Spider. I have a line:


          NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged);

which works great when I either pull or push the cable in and out. However, if the cable is in initially, how to I get to find out if the network is up (or down) as it only fires on a state change. In case it matters I have a static IP address.

look in documentation for Ethernet class in GHI.Premium.Net namespace. there is a property for cable connected.

@ Mike, there isn’t a GHI.Premium.Net DLL. Where did you get yours from ?

What board are you using?

@ Ian,

[quote=“davestone”]
work with my Spider. [/quote]

I guess there was a change with 4.2. I guess a little bit of searching is necessary. :slight_smile:

The DLL is still not there. This comes with wifi. Please see release notes.

Actually it fires on start-up too! but it fires before the application starts. This is not helpful piece of information I know :).

@ Joe, I’m converting my Spider into a time machine so I can go back and catch the event. :slight_smile:

Meanwhile… I’m assuming the answer is a "[em]no workaround[/em]’ until the GH.Premium DLL becomes available. Any views on when that might be, just so as I can pace myself.

An idea like this…

What about a thread that keeps pinging a known IP address, and when is not reachable, throw an UnreachableEvent, and when back reachable, throw a ReachableEvent ?

Can it be a way to work around ?

The MIP TCP stack for the ENC28 has a link up/down event. Although, be warned, the usage is different from the standard TCP stack and it may be buggy…

http://mip.codeplex.com

Pinging the default gateway is good way to verify if the connection is there or not.

Is there a ping method?

Ping is like sending 32 octets of datas to the target using ICMP, and waiting for it to respond… I have a code on this somewhere and will look at in this week and send back if available…

@ LouisCppro - thanks for your suggested workaround. Much appreciated.

Here’s the link to the code I promized. It is originally for the standard Framework, but I guess it wont be difficult to port as it only use low level socket implementations…

http://www.codeproject.com/Articles/13174/ICMP-the-ping-tracert

Not that it can also be used for tracert…

Hope this will help.

If you port, do not hesitate to feedback with the changed class on codeshare.