mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-16 11:21:18 +03:00
Proposed fix for issue 243, adding DNS to the Ethernet library. Uses a slightly modified version of the agreed API as the host/port parameters have been moved from the Client constructor to the Client::connect methods. This means it's possible for errors to be returned if the DNS lookup fails and also reduces the RAM footprint of the Client class as it no longer needs to store the host/port for later use in Client::connect.
This commit is contained in:
@ -23,7 +23,7 @@ IPAddress server(173,194,33,104); // Google
|
||||
// Initialize the Ethernet client library
|
||||
// with the IP address and port of the server
|
||||
// that you want to connect to (port 80 is default for HTTP):
|
||||
Client client(server, 80);
|
||||
Client client;
|
||||
|
||||
void setup() {
|
||||
// start the serial library:
|
||||
@ -40,7 +40,7 @@ void setup() {
|
||||
Serial.println("connecting...");
|
||||
|
||||
// if you get a connection, report back via serial:
|
||||
if (client.connect()) {
|
||||
if (client.connect(server, 80)) {
|
||||
Serial.println("connected");
|
||||
// Make a HTTP request:
|
||||
client.println("GET /search?q=arduino HTTP/1.0");
|
||||
|
Reference in New Issue
Block a user