Textfinder on Arduino MEGA with Ethernet

I'm developping with IDE 1.0.1 and current version of TextFinder a Ethernet Stream parser. I do read only the first 100 bytes and parse the content with finder.getValue() into a object in ram.
A typicall request by current browser will be as long as 450 bytes and take arround 155ms to be read on Arduino.

Does anyone know what would happen with the (arround 300 bytes) unread data from Ethernet Shield when doing client.stop()?

Going into the libary. They wrote a myRead() with a included timeout. It allways brings the code to this timeout loop when no data is available. (if condition has no else condition). I rewrote the 5seconds to 100ms timeout in the lib. But anyway, hanging there in the loop is mess.

Regards, Markus

Can you control how many bytes are read, ie 100 in your example ?
Can you use the findUntil function instead. It seems that you can continue the search at the point where the first value was found.

Does anyone know what would happen with the (arround 300 bytes) unread data from Ethernet Shield when doing client.stop()?

Yes. The data stays in the rx buffer, and normally the connection will not close correctly until it is empty. Now you have 3 sockets remaining.

@UKHeliBob: yes, arround 40 byte are read. The HTTP request by google browser starts with

GET /&dev=250&val=24\n\rConnection. ....

Im only interest having the val and dev value in my arduino-code. How do I get rid of the last 350 bytes?

@SurferTim: Thanks for the hit with the socket. It looks then one should hardly clear all the conent in rx buffer. What would be the fastest way for skipping this data? May I bring in then somethin like (what will take some time: my guess - not collected any data now: 400ms)
while (client.avalible()>0) { client.read(); } or while (client.read()>0) { }.

If this is a GET request, the signal the client is finished sending is a blank line (double cr/lf). Read packets until then. Here is my server code that does just that. Maybe this code will help you.

Thanks for this. I was surprise. This code in your link is different than in the download libary ZIP-file.

They just went throught the full request string with while(client.available()) and char c = client.read(); Hence, there's none command to get rid of the nonreaded rx-buffer data corresponding to the client object opened?

I can't vouch for anyone's code but mine. When I started using the ethernet shield, I couldn't get any example web code to work for any length of time. Mine has been tested and is very reliable.

edit: It was worse than that, actually. I couldn't get the ethernet shield to work at all. It required modifications to the libraries to prevent it from locking up.

Thanks for this hint: I was looking in the post and found your entry on nongnu.org with the missing entry in delay.h with "#include <math.h>". I'm not sure if you reference to this entry? The complailer doesn't report any error in my IDE 1.0.1 (no idea from here what avr version is laying down).

What modification did you do?

The "605 bug" is the ethernet problem. It caused me grief for a couple months.

It was corrected in IDE v1.0.1.


I couldn't get working the TextFinder .getValue() function for this evening. Hence, I tried to use the SurferTim's code. I cannot get working the (client) at all. Beside, is there any tutorial about atoi and

void loop() {
  client = Server.available();
  int tCount = 0;
  char tBuf[41];
  char *pch;
  if (client) {
    while (client.connected()) {
      if (client.available()) {
          char c = client.read();
          if(tCount < 41) {
            tBuf[tCount] = c;
            tBuf[tCount] = 0;            
          else {
            while(client.available()) Serial.write(client.read());
            pch = strtok(tBuf,"=");
            while(pch != NULL) {
              if(strncmp(pch,"dev=",4) == 0)  {
                eth.device = atoi(pch+4);
              if(strncmp(pch,"com=",4) == 0) {
                eth.command = atoi(pch+4);
              pch = strtok(NULL,"& ");
    } // connected
  }  //client
} //loop

is there any solution for ready serial byte values (from 0 to 255) with atoi? My value may be 3 byte in the ethernet stream.

This is my request string:

is there any solution for ready serial byte values (from 0 to 255) with atoi?

No. You don't seem to have a clue what atoi() does.

Right. I was looking yesterday into some tutorial for atoi(). Seems to by "my" function... I'will test again this evening.