Go Down

Topic: connection failed:Ethernet NKC (Read 459 times) previous topic - next topic

sandroalex

Hello everyone, I have Ethernet shield of NKC. I tried to test it with the sketch "WebClient" but I have as a result: connection failed. I hope can help me.

Sandro

sandroalex

     
This is the code:
Quote
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 201, 204, 204, 51 };
byte server[] = { 64, 233, 187, 99 }; // Google

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 /search?q=arduino HTTP/1.0");
   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(;;)
     ;
 }
}


thanks a lot

Digger450

Are you sure about the server IP?  It's dead for me it I try to ping it.

sandroalex

     
I dont Know why I do not have favorable results with ethernet library.
But if you are using site

http://code.google.com/p/webduino/

It went well. :)

Go Up