Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

icabodcam

Member Since 05 May 2014
Offline Last Active Dec 07 2017 04:36 AM
-----

Posts I've Made

In Topic: New Machine--no drivers

13 April 2016 - 07:10 PM

No, not in the 4.3.2.1.  I don't know if the drivers would work that are in the 4.2.2 listed for the Netduino (not +) and mini.

 

We should probably look into storing some of this stuff in a cloud location if needed in the future...


In Topic: NetworkInterface.OperationalStatus

28 April 2015 - 05:54 PM

I believe that I've got a solution. 

Reminded in this thread by Nobby, the Socket.Poll method was the solution. 

 

So the solution looks something like this in the constructor for the listener class:

try
            {
                Debug.Print(NetworkInterface.GetAllNetworkInterfaces()[0].IPAddress);
                listeningSocket.Bind(new IPEndPoint(IPAddress.Any, portNumber));
                listeningSocket.Listen(10);
                bool testConnection = listeningSocket.Poll(500,SelectMode.SelectRead);
            }
            catch (SocketException)
            {
                isNetworkAvailable = false;
                listeningSocket.Close();
            }

Then in the method or thread that handles the listener, test the status of isNetworkAvailable before using the socket, kind of like:

if (isNetworkAvailable)
                {
                    try
                    {
                        using (Socket clientSocket = listeningSocket.Accept())
                        {
                            ...
                        }

...and in the
NetworkAvailabilityChanged handler if network not available then close the socket, else recreate the socket, bind, and start listening.

 

I hope that helps someone else. 


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.