Hello guys,
It seems that the NetworkAvailabilityChanged is not triggered when the board starts with a cable attached… to me it should trigger and report True, when the board starts with the network cable attached to a router… right now we have no way to detecting the network is up reliably…
here is a test code.
void ProgramStarted()
{
NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
Interfaces = NetworkInterface.GetAllNetworkInterfaces();
_networkInterface = Interfaces[0];
if (_networkInterface.IsDhcpEnabled == false) _networkInterface.EnableDhcp();
}
void NetworkChange_NetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e)
{
Debug.Print("Network Availability Changed: " + e.IsAvailable);
}
as it stands now, the code has no way of knowing the state of the Net Cable when it starts…
another issue I noticed is when I bind to a UDP port I unplug the cable, close the socket, free it… reconnect the cable try to bind to the same IP and Port I get an exception, if I change the Cable to a different Port on the Router it works as expected, and NO the IP Address is always the same and hasn’t changed… why?
Oh yah the NetworkAddressChanged is unreliable as it kicks in once in a moon, where it should kick in when the cable is plugged and a new IPAddress is assigned, remind you that the board starts with no IPAddress…so it must trigger as well… and when the cable is unplugged it should kick in again with NO IPAddress… and so on…
NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
I hope you guys run few tests when you work on the networking stack…