Hello.
I'm new to this forum since most of the time the examples en forum discussions were enough to solve my problems with Arduino.
In this topic
https://forum.arduino.cc/index.php?topic=168374.0
TM describes his problem of connecting to a client where the IP connection works fine, the URL connection does not.
In my set up this is the other way around. The URL works fine, IP does not. I've tried all kinds of things, with existing websites.
Also, different ethernet libs have different results. With the 2.0.0. the URL doesn't work either.. Currently using 1.1.2.
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
//byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0x40, 0xF3 };//mac address on board sticker
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(192, 168, 0, 40); // numeric IP for Google (no DNS), NOK
//IPAddress server(74, 125, 232, 128); // numeric IP for Google (no DNS), NOK
//IPAddress server(216, 58, 212, 142); // numeric IP for Google (no DNS), NOK
//IPAddress server(139, 130, 4, 5); // telstra australia, NOK
//byte server[] = { 74,125,232,128 }; // Google, NOK
char server[] = "www.google.com"; // name address for Google (using DNS), Ok
//char server[] = "ns1.telstra.net"; // Ok
EthernetClient client;
void setup() {
Serial.begin(9600);
Serial.print("check IP");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.print("connected to ");
//Serial.println(client.remoteIP());
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.1");
//client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
beginMicros = micros();
}
Help would really be appreciated..