Reducing code size on Arduino Ethernet boards

The Ethernet library grew in size several KB from 0022 to 1.0, which is a big deal when you only have 32 KB to play with. You can save about 2 KB by compiling out DNS support:

Wrap the following pieces of code in #if WITH_DNS

  • Dns.cpp and Dns.h:
    The entire file
  • EthernetClient.h and EthernetClient.cpp:
    int connect(const char* host, uint16_t port)
  • EthernetUDP.h and EthernetUDP.cpp:
    int beginPacket(const char *host, uint16_t port)
  • Client.h:
    virtual int connect(const char *host, uint16_t port)
  • Udp.h:
    virtual int beginPacket(const char *host, uint16_t port)

Add #include "EthernetUDP.h" to EthernetUDP.cpp, since it’s currently relying on the indirect include from Dns.h.