user7572: I want to access the following page on my local using my Arduino with ethernet shield"  192.168.1.2/zombie/arduino.php.  My arduino is conencted to a PC through a router. The system keeps timing out
I am using the following code:
#include <Ethernet.h>
#include <SPI.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,3 };
char server[] = "192.168.1.2/zombie/arduino.php";

EthernetClient client;

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  int res = client.connect(server, 80);

  Serial.println(res);

  if (res) {
    Serial.println("connected");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.println("data:");
    Serial.println(c);
  }else{
    Serial.println("NA");
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}


user7572: I discovered the answer after some testing.
The server var:
char server[] = "192.168.1.2/zombie/arduino.php";

should only contain the ip address.  So it should look like this:
byte server[] = { 192,168,1,2 };

The additional URL elements should be added using:
client.println("GET /zombie/arduino.php");

after a connection has been established
The final code should look like this:
#include <Ethernet.h>
#include <SPI.h>


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,3 };
byte server[] = { 192,168,1,2 };

EthernetClient client;

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  int res = client.connect(server, 80);

  Serial.println(res);

  if (res) {
    Serial.println("connected");
    client.println("GET /zombie/arduino.php");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.println("data:");
    Serial.println(c);
  }else{
    Serial.println("NA");
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}


7572: <p>I want to access the following page on my local using my Arduino with ethernet shield"  192.168.1.2/zombie/arduino.php.  My arduino is conencted to a PC through a router. The system keeps timing out</p>

<p>I am using the following code:</p>

<pre><code>#include &lt;Ethernet.h&gt;
#include &lt;SPI.h&gt;


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,3 };
char server[] = "192.168.1.2/zombie/arduino.php";

EthernetClient client;

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  int res = client.connect(server, 80);

  Serial.println(res);

  if (res) {
    Serial.println("connected");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.println("data:");
    Serial.println(c);
  }else{
    Serial.println("NA");
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}
</code></pre>
 7572: <p>I discovered the answer after some testing.</p>

<p>The server var:</p>

<pre><code>char server[] = "192.168.1.2/zombie/arduino.php";
</code></pre>

<p>should only contain the ip address.  So it should look like this:</p>

<pre><code>byte server[] = { 192,168,1,2 };
</code></pre>

<p>The additional URL elements should be added using:</p>

<pre><code>client.println("GET /zombie/arduino.php");
</code></pre>

<p>after a connection has been established</p>

<p>The final code should look like this:</p>

<pre><code>#include &lt;Ethernet.h&gt;
#include &lt;SPI.h&gt;


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192,168,1,3 };
byte server[] = { 192,168,1,2 };

EthernetClient client;

void setup()
{
  Ethernet.begin(mac, ip);
  Serial.begin(9600);

  delay(1000);

  Serial.println("connecting...");

  int res = client.connect(server, 80);

  Serial.println(res);

  if (res) {
    Serial.println("connected");
    client.println("GET /zombie/arduino.php");
    client.println();
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.println("data:");
    Serial.println(c);
  }else{
    Serial.println("NA");
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
}
</code></pre>
