Ethernet Check Network Connection

Hi,
i need some help.

I want to check the network connection from my arduino. not to check if its connected with the internet, only to the local network.
My actualy methode is this:

EthernetClient test;

if(test.connect(Gateway,80))
	{
		Online = true;
		return 1;
	}
	else 
	{
		Online = false;
		return -1;
	}

The code test ever second to connect to the gateway (router). The problem is that the router couldnt manage so many request and the network is broken.
Is there a better way to test the connection?

sorry for my bad english :slight_smile:

Greetz

The code test ever second to connect to the gateway (router). The problem is that the router couldnt manage so many request and the network is broken. Is there a better way to test the connection?

There is nothing in that snippet that demonstrates that the test only occurs once per second. Why is it necessary to test that often? What do you propose to do if you can't connect to whatever is in the Gateway variable?

The router should easily be able to cope with one request per second. What happens to the network ?

I call this code every second withhelp from millis()... After some minutes theres no communication form pc to router. But if i unplugged the networkcable form the arduino or turn off, the network runs...

I need this, because i want to know if maybe the networkcable is unplugged, router is down or something...

I believe that the connect method creates a new connection every time that it is used so called every second I can quite believe that the router cannot cope. There is another method, connected which would seem to just check if the connection is alive rather than creating a new one. Perhaps you could give that a try.

NOTE - I have taken this information from this page http://arduino.cc/en/Reference/EthernetClient but not having an Ethernet shield I cannot be sure that my assumption is correct.

I don't know if this would help or not, but my first thought on checking to make sure an Ethernet device is active on it's directly connected network would be to ping the gateway. Figuring that the various ethernet libraries don't have higher level functions like ping embedded (I could be wrong), I did a quick Google search on "arduino ethernet ping" and among many other hits I found this 2010 thread here: http://forum.arduino.cc/index.php/topic,8701.0.html This person links to an ICMP Ping library that he developed. I haven't checked it out myself, but it might be an option for you.