Netduino home hardware projects downloads community

Jump to content


Photo

Netduino.IP feature: GetIsNetworkAvailable()


  • Please log in to reply
No replies to this topic

#1 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 09 May 2015 - 05:58 PM

We received quite a few requests for a simple function which determines whether the network connection is live or not.

So with Netduino.IP (both the full stack and the hybrid stack used on Netduino 3 Wi-Fi), we have implemented System.Net's GetIsNetworkAvailable method.

To use this, simply add NetduinoExtensions.dll to your project. This new assembly is included in the 4.3.2.1 SDK (or newer).

Here is some code which retrieves the current network connection state:
// wait for network connectivity
bool isNetworkAvailable = System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable();
If you're using DHCP (instead of static IP), you can also determine if you have received a DHCP-allocated IP address. This works with both lwIP and Netduino.IP.
IPAddress ipAddress = IPAddress.GetDefaultLocalAddress();
Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.