Possible Arduino 1.0.1 Ethernet Library bug?

I'm always suspect of various suspect test methods themselves sending the dogs chasing their tails. just something to consider.

Absolutely agree with this zoomkat. How many times does this happen??

Anyway.. after some further investigation and lots of testing.....

I used three independent instances of Webinject to load up ST's form sketch with 1000's of simple GETs and everything worked ok. So the ethernet library can logically handle more than one socket connected at the same time.

BUT this result made me question under what circumstances I was seeing responses being lost and what was different??

There are two possible differences:

  1. The character length of the GET headers being received by the W5100 is much longer.

  2. Any processing delay in the sketch when the GET characters are being read from the W5100 RX buffer

So I did some Webinject tests with much bigger GET headers and increased the GET processing delay in ST's sketch.

Testing showed that either a bigger GET header OR more GET processing delay caused many GET responses to be lost.

For example if a delay(10) is added in STs sketch where the GET header is read

    Serial.print("Client request: ");
    
    while (client.connected()) {
      while(client.available()) {
        char c = client.read();
delay(10); // added delay
        if(currentLineIsGet && tCount < 63)
        {
          tBuf[tCount] = c;
          tCount++;
          tBuf[tCount] = 0;          
        }

There were many GET response failures (around 50%) when I ran the three Webinject instances again. Increasing the GET header size just makes it worse. Even a small delay of delay(2) causes GET responses to be lost.

It looks to me like there is a problem in the Ethernet library when the RX buffer is not being read quickly enough. For example the RX buffer may be being overwritten by another GET arriving later.

If there is a W5100 RX buffer read bug this would explain the problems I've seen with my Web Server sketch. The GETs it is receiving come from IE9 and Firefox where the GET headers are big (especially for IE9). And my GET processing is fairly complex with files being openned which would add a few milliseconds to the GET processing time.

My next step is to look more closely at the W5100 RX read code in the Ethernet Library.