How to detect gadgeteer- LAN disconnected

I’m using TCP, is there any way to detect that the gadgeteer is disconnected.
the regular approach of poll and available check

public bool IsConnected
{
         get {return !(Socket.Poll(1, SelectMode.SelectRead) 
                                  && m_socket.Available ==0)}
}

does not return false also when disconnected.

if I’m trying to send data every specific interval at the end there will be an IO EXcpetion buit that is also only after half a second.
any ideas?

Which mainboard / network module are you using? There should be a networkup and networkdown event on the J11D and ENC28 modules



        void ProgramStarted()
        {
            Debug.Print("Program Started");

            ethernet_J11D.NetworkDown += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_J11D_NetworkDown);
            ethernet_J11D.NetworkUp += new GTM.Module.NetworkModule.NetworkEventHandler(ethernet_J11D_NetworkUp);
        }

        void ethernet_J11D_NetworkUp(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            throw new NotImplementedException();
        }

        void ethernet_J11D_NetworkDown(GTM.Module.NetworkModule sender, GTM.Module.NetworkModule.NetworkState state)
        {
            throw new NotImplementedException();
        }


Lots of examples in CodeShare.

My experience tells me that you can check for zero bytes in the stream when you poll, and in that case conclude. Network down. Relying on the events are unfortunately not good enough for stable network code.

Want to join the “stable network code task-force”?