Ethernet shield data usage?

Now that my arduino is acting as a we bclient, how do I take the data it gets back and do things with it?

Like:
if (clientoutput == “it works”) {
dothis;
}

My Arduino code:

#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 30 };
byte server[] = { 192, 168, 1, 31 };
//char getdata = '1';
Client client(server, 80);

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  
  delay(1000);
  
  Serial.println("connecting...");
  
  if (client.connect()) {
    Serial.println("connected");
    client.println("GET /script.php?getdata=1 HTTP/1.0");
    //client.println(getdata);
    //client.println(" HTTP/1.1");
    //client.println("Host: http://192.168.1.31");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }
  
  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}

PHP code

<html>

<?php

if ($_GET[getdata] == "1") {

echo "it works";

} else {

echo "no var";

}

?>

on wich OS are you on?

Windows = a no go... Mac = Do'nt really know i never had a mac (because i think they suck). Linux = a YES.

SaSaa, I don’t think your reply is in the least helpful. Firstly, platform doesn’t matter - I reckon I could get php to pipe data to whatever application I want on any system it’ll run on.

Secondly, I don’t think that’s what the original poster was after.

tehjrow - have a look at cowjam.net at the counter project. It polls a php site for data, then actions it. This is the main bit of the code:

  client.println("GET /url.php HTTP/1.0");
  client.println();
  foo=0;
  while (foo<8) {  //dump unwanted lines
    while (client.read() != '\n') { }
    foo++;  
  }
  if (client.read() == 'Y') {
    client.flush();
    client.stop();
    return true;
  } else {
    client.flush();
    client.stop();
    return false; 
  }

What it does:
connect to a website (url.php).
the first eight lines are header info - not the HTML you’re expecting. I don’t know if this varies by server so you might want to check, but on my server the first eight lines are rubbish so I dump them.
Check the contents of the HTML. In this case, it’s either a Y or N (no html layout or anything, just a Y or N).
the code is part of a function. If a Y is receive it returns true.

You might also want to look at the twitter code on cowjam.net - very similar technology but the grab from the URL is more complex.

Actually, his reply does contain some useful reminders, if you've been around the forum for a while.

On Windows, PHP can't read from the serial port. This is not a limitation of PHP as much as it is the fact that the brain dead morons up the road at Microsoft didn't think that reading from the serial port is something that an non-Microsoft application needs to be able to do, so the necessary APIs are not exposed (or just don't work).

On Linux, PHP can read from the serial port.

This is not a limitation of PHP…

Well, yes it is. As best as I remember, PHP was developed to make dynamic web pages, generally sending/receiving and slicing/dicing information from various types of files with no mention of hardware I/O operations. PHP’s only connection to the serial port on windows is that on windows one can send data to the serial port (com1, etc) as it appears as a file when accessed in ths format. PHP apparently accesses the serial port the same as the below batch file. If one wants to serial port I/O operations on windows, then one can use an appropriate application made to do the job.

@echo off
echo Hello World >com1