Receive String from Ethernet Shield/Server

Hello All, I have an Arduino Ethernet that is hooked up to a serial LCD screen from Spark Fun. The screen is a 20x4. I have the screen working with the Arduino already and can statically print strings on the screen. However, I want to send a packet to the Arduino via Ethernet that contains the strings to print on the screen. What is the best way to implement this? I was thinking the packet that I send to the Arduino will have a newline character to tell me when to break up the string into the next line and so on. I can't seem to wrap my head around how to do this. I can already setup the Ethernet server with no issue, I am mainly stuck on how to receive/parse the string. I know this much:

EthernetClient client = server.available();

if (client == true) {
  
  while (client.connected()){
    
    if (client.available() ) {
      
        parseString(client);  //Would a method call to handle this be right or should I parse it right here?  And how would I parse each line out assuming I use a newline to seperate?  Should I globally declare four strings to put each in?
              
    }
  }
}

Basic server code that captures what is sent from the client in the readString variable.

//zoomkat 12-8-11
//simple button GET with iframe code
//for use with IDE 1.0
//open serial monitor to see what the arduino receives
//use the \ slash to escape the " in the html (or use ')
//address will look like http://192.168.1.102:84 when submited
//for use with W5100 based ethernet shields

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port

String readString; 

//////////////////////

void setup(){

  pinMode(5, OUTPUT); //pin selected to control
  //start Ethernet
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();

  //enable serial data print 
  Serial.begin(9600); 
  Serial.println("server LED test 1.0"); // so I can keep track of what is loaded
}

void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {

          //store characters to string 
          readString += c; 
          //Serial.print(c);
        } 

        //if HTTP request has ended
        if (c == '\n') {

          ///////////////
          Serial.println(readString); //print to serial monitor for debuging 

          //now output HTML data header
             if(readString.indexOf('?') >=0) { //don't send new page
               client.println("HTTP/1.1 204 Zoomkat");
               client.println();
               client.println();  
             }
             else {
          client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Arduino GET test page</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>Zoomkat's simple Arduino button</H1>");
          
          client.println("<a href=\"/?on1\" target=\"inlineframe\">ON</a>"); 
          client.println("<a href=\"/?off\" target=\"inlineframe\">OFF</a>"); 

          //client.println("<IFRAME name=inlineframe src=\"res://D:/WINDOWS/dnserror.htm\" width=1 height=1\">");
          client.println("<IFRAME name=inlineframe style=\"display:none\" >");          
          client.println("</IFRAME>");

          client.println("</BODY>");
          client.println("</HTML>");
             }

          delay(1);
          //stopping client
          client.stop();

          ///////////////////// control arduino pin
          if(readString.indexOf("on1") >0)//checks for on
          {
            digitalWrite(5, HIGH);    // set pin 4 high
            Serial.println("Led On");
          }
          if(readString.indexOf("off") >0)//checks for off
          {
            digitalWrite(5, LOW);    // set pin 4 low
            Serial.println("Led Off");
          }
          //clearing string for next read
          readString="";

        }
      }
    }
  }
}

What Zoomkat is saying is that if you get your Arduino ethernet to display a web page a user can enter data into the page (such as a data entry field) and press a submit button (or select a URL link) to send data back to your Arduino ethernet device.

For example when I enter a password into the login screen of my Arduino ethernet application at www.2wg.co.nz and press the Submit button this is the kind of data that is sent back to my Arduino:

Host: www.2wg.co.nz
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-nz,th;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: http://www.2wg.co.nz/56727/
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 18
<<IMPORTANT BLANK LINE SEPARATOR IS HERE>>
PASSWORD=AVALUE%34

My system parses this information to extract the password (AVALUE%34 is not the real one) and then reports what it has determined from the above input and other sources as follows:

<< CONNECTION >>
IP: 222.154.229.4
Socket #: 2
Dest Port: 49673
<< PARSE RESULT >>
HOST WWW.2WG.CO.NZ
PAGE Password Login
PASSWORD OK

Within my application the successful entry of a password causes the application to assign a session cookie which allows the user to remain logged in for ten minutes. This login status gives the user access to much more application functionality.

Once you have parsed and extracted your web page input data you can do whatever your application needs to do.

You don’t need to use a browser to send the above information to your Arduino. Any application that can generate the correct content and send it to your Arduino ethernet device on the correct port is able to upload data.

Cheers

Catweazle NZ