Go Down

Topic: BUG in example: https://www.arduino.cc/en/Reference/EthernetServer (Read 85 times) previous topic - next topic


Hi all!

I realized a bug in the example code posted on some reference pages of EthernetServer:

In all those pages, the Ethernet object is called by the wrong sequence of parameters:

  // initialize the ethernet device
  Ethernet.begin(mac, ip, gateway, subnet);

The correct sequence of parameters is posted in the Ethernet.begin() reference page:

  Ethernet.begin(mac, ip, dns, gateway); 

This results in a confusing problem:
1) The example code works fine on IP link-local level, where no gateway is needed, eg. when you connect the Arduino Ethernet-shield directly to your PC. - Probably the reason nobody realised this yet. ;)
2) The example code does _not_ work when the Arduino is behind a router in another subnet, because the gateway is probably set to, which is most certainly wrong.

The fact that the DNS is also wrong is not relevant, because the EthernetServer does not need to know a DNS server in the first place.

Go Up