WiFi Shield - Buffering outsending data

Hi all,

I have done some more tests.

Ethernet Shield code

...
IPAddress ip(192,168,1,220);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);

EthernetServer server(80);

...

void loop() {
  
  // listen for incoming clients
  EthernetClient client = server.available();
  
  if (client) {
    
    Serial.println("new client");
            
    while (client.connected()) {

      // Receiving data

      if (client.available()) {
        
        char c = client.read();
        Serial.write(c);
      }
      
      // Sending data
      
      for(int i=0; i<500; i++) {
            
        char buffer[30];
      
        sprintf(buffer,"%s=%d#", "Pot", i);

        client.write((const uint8_t *)buffer, strlen(buffer)*sizeof(char));  
      }

    }

    delay(1);
    
    client.stop();
    Serial.println("client disconnected");
  }
 
}

The client receives messages continuously

2012-09-01 10:40:06.540 ConnectTest[3870:403] Pot=0#
2012-09-01 10:40:06.544 ConnectTest[3870:403] Pot=1#
2012-09-01 10:40:06.545 ConnectTest[3870:403] Pot=2#Pot=3#Pot=4#Pot=5#Pot=6#Pot=7#Pot=8#Pot=9#Pot=10#Pot=11#Pot=12#Pot=13#
2012-09-01 10:40:06.546 ConnectTest[3870:403] Pot=14#
2012-09-01 10:40:06.548 ConnectTest[3870:403] Pot=15#Pot=16#Pot=17#
2012-09-01 10:40:06.549 ConnectTest[3870:403] Pot=18#Pot=19#Pot=20#Pot=21#
2012-09-01 10:40:06.551 ConnectTest[3870:403] Pot=22#Pot=23#Pot=24#Pot=25#Pot=26#
2012-09-01 10:40:06.553 ConnectTest[3870:403] Pot=27#Pot=28#Pot=29#Pot=30#Pot=31#
2012-09-01 10:40:06.556 ConnectTest[3870:403] Pot=32#Pot=33#Pot=34#Pot=35#Pot=36#Pot=37#
2012-09-01 10:40:06.557 ConnectTest[3870:403] Pot=38#Pot=39#Pot=40#Pot=41#Pot=42#Pot=43#Pot=44#Pot=45#
2012-09-01 10:40:06.559 ConnectTest[3870:403] Pot=46#Pot=47#Pot=48#Pot=49#Pot=50#
2012-09-01 10:40:06.560 ConnectTest[3870:403] Pot=51#Pot=52#Pot=53#Pot=54#Pot=55#
2012-09-01 10:40:06.562 ConnectTest[3870:403] Pot=56#Pot=57#Pot=58#Pot=59#
2012-09-01 10:40:06.563 ConnectTest[3870:403] Pot=60#Pot=61#Pot=62#Pot=63#
2012-09-01 10:40:06.567 ConnectTest[3870:403] Pot=64#Pot=65#Pot=66#Pot=67#
2012-09-01 10:40:06.570 ConnectTest[3870:403] Pot=68#Pot=69#Pot=70#Pot=71#Pot=72#Pot=73#Pot=74#Pot=75#Pot=76#

WiFi Shield code

...
WiFiServer server(80);
...

void loop() {
  
  // listen for incoming clients
  WiFiClient client = server.available();
  
  if (client) {
    
    Serial.println("new client");
            
    while (client.connected()) {
      
      // Receiving data

      if (client.available()) {
        
        char c = client.read();
        Serial.write(c);
      }
      
      // Sending data
      
      for(int i=0; i<500; i++) {
            
        char buffer[30];
      
        sprintf(buffer,"%s=%d#", "Pot", i);

        client.write((const uint8_t *)buffer, strlen(buffer)*sizeof(char));          
      }

    }

    delay(1);
    
    client.stop();
    Serial.println("client disonnected");
  }
}

The client receives messages in bunch and a delay of about 2 secs between different bunches.

2012-09-01 10:32:40.359 ConnectTest[3475:403] Pot=0#Pot=1#Pot=2#Pot=3#Pot=4#Pot=5#Pot=6#Pot=7#Pot=8#Pot=9#Pot=10#Pot=11#Pot=12#Pot=13#Pot=14#Pot=15#Pot=16#Pot=17#Pot=18#Pot=19#Pot=20#Pot=21#Pot=22#Pot=23#Pot=24#Pot=25#Pot=26#Pot=27#Pot=28#Pot=29#Pot=30#Pot=31#
2012-09-01 10:32:40.360 ConnectTest[3475:403] Pot=32#
2012-09-01 10:32:42.096 ConnectTest[3475:403] Pot=33#Pot=34#Pot=35#Pot=36#Pot=37#Pot=38#Pot=39#Pot=40#Pot=41#Pot=42#Pot=43#Pot=44#Pot=45#Pot=46#Pot=47#Pot=48#Pot=49#Pot=50#Pot=51#Pot=52#Pot=53#Pot=54#Pot=55#Pot=56#Pot=57#Pot=58#Pot=59#Pot=60#Pot=61#Pot=62#Pot=63#Pot=64#
2012-09-01 10:32:42.098 ConnectTest[3475:403] Pot=65#
2012-09-01 10:32:44.120 ConnectTest[3475:403] Pot=66#Pot=67#Pot=68#Pot=69#Pot=70#Pot=71#Pot=72#Pot=73#Pot=74#Pot=75#Pot=76#Pot=77#Pot=78#Pot=79#Pot=80#Pot=81#Pot=82#Pot=83#Pot=84#Pot=85#Pot=86#Pot=87#Pot=88#Pot=89#Pot=90#Pot=91#Pot=92#Pot=93#Pot=94#Pot=95#Pot=96#Pot=97#
2012-09-01 10:32:44.126 ConnectTest[3475:403] Pot=98#
2012-09-01 10:32:46.144 ConnectTest[3475:403] Pot=99#Pot=100#Pot=101#Pot=102#Pot=103#Pot=104#Pot=105#Pot=106#Pot=107#Pot=108#Pot=109#Pot=110#Pot=111#Pot=112#Pot=113#Pot=114#Pot=115#Pot=116#Pot=117#Pot=118#Pot=119#Pot=120#Pot=121#Pot=122#Pot=123#Pot=124#Pot=125#Pot=126#Pot=127#Pot=128#Pot=129#Pot=130#
2012-09-01 10:32:46.147 ConnectTest[3475:403] Pot=131#
2012-09-01 10:32:48.169 ConnectTest[3475:403] Pot=132#Pot=133#Pot=134#Pot=135#Pot=136#Pot=137#Pot=138#Pot=139#Pot=140#Pot=141#Pot=142#Pot=143#Pot=144#Pot=145#Pot=146#Pot=147#Pot=148#Pot=149#Pot=150#Pot=151#Pot=152#Pot=153#Pot=154#Pot=155#Pot=156#Pot=157#Pot=158#Pot=159#Pot=160#Pot=161#Pot=162#Pot=163#
2012-09-01 10:32:48.171 ConnectTest[3475:403] Pot=164#

This indicates that somewhere there is a buffer which has to be filled before data are sent to the client.

Does anyone know how to change this behavior ?