My Enc28J60 chip cannot connect as a web client although it's works fine as a web server!
the chip connected to laptop which has a wireless connection with the router and i use Enc28j60 library and IDE 0023(the original Ethernet library was removed from the library folder).
the web client code:
#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 105 }; // my ethernet ip is(192.168.1.104) so this is in the same subnet
byte server[] = { 173, 194, 70, 138 }; //google ip
Client client(server, 80);
void setup() {
Ethernet.begin(mac, ip);
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect()) { // i think the problem is here?!
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(;; )
;
}
}
the serial monitor output:
connecting...
connection failed
disconnecting.
i spent 2 weeks searching for solutions :S could any one help me in this problem?
thanks in advance