Ethernet icon indicating copy to clipboard operation
Ethernet copied to clipboard

w5100 buffer overflow

Open agdl opened this issue 8 years ago • 0 comments

From @WildOrangutan on May 14, 2015 22:49

Hi! Please implement something like this, to avoid w5100 buffer overflow, when constantly sending data as fast as possible:

int EthernetClient::free() {
    if (_sock != MAX_SOCK_NUM)
        return W5100.getTXFreeSize(_sock);
   return 0;
}

And then use it in examples like this:

while (file.available() > 0) {
    if (client.free() > 0) { // This was key to solving the issue
        c = file.read();
        client.print((char)c);
    } else { // No free buffer? Ok, I'll wait a couple of millis...
        delay(1);
    }
}
file.close();

Source: http://www.toptal.com/c/how-i-made-a-fully-functional-arduino-weather-station-for-300

Copied from original issue: arduino/Arduino#3144

agdl avatar Jul 12 '16 13:07 agdl