Reference.EthernetClient History

Hide minor edits - Show changes to output

November 09, 2011, at 09:27 PM by Scott Fitzgerald -
Changed lines 28-29 from:
EthernetClient client();
to:
EthernetClient client;
November 09, 2011, at 09:19 PM by Scott Fitzgerald -
Changed lines 21-23 from:
to:
#include <SPI.h>

Changed lines 28-29 from:
EthernetClient client(server, 80);
to:
EthernetClient client();
Changed line 39 from:
if (client.connect()) {
to:
if (client.connect(server, 80)) {
November 09, 2011, at 09:18 PM by Scott Fitzgerald -
Changed lines 7-8 from:
Creates a client which can connect to the specified internet IP address and port. Also supports DNS lookups when using a domain name.
to:
Creates a client which can connect to a specified internet IP address and port (defined in the [[/Reference/ClientConnect | client.connect()]] function).
Changed lines 11-13 from:
EthernetClient(ip, port)\\
EthernetClient(URL, port)
to:
EthernetClient()
Changed lines 15-20 from:
ip: the IP address that the client will connect to (array of 4 bytes)

URL: the domain name the client will connect to (string, ex.:"arduino.cc")

port: the port that the client will connect to (int)
to:
None
November 01, 2011, at 04:33 PM by Scott Fitzgerald - Page Creation
Added lines 1-66:
[[Ethernet]] : ''EthernetClient''

!!EthernetClient()

!!!!Description

Creates a client which can connect to the specified internet IP address and port. Also supports DNS lookups when using a domain name.

!!!!Syntax

EthernetClient(ip, port)\\
EthernetClient(URL, port)

!!!!Parameters

ip: the IP address that the client will connect to (array of 4 bytes)

URL: the domain name the client will connect to (string, ex.:"arduino.cc")

port: the port that the client will connect to (int)

!!!!Example

(:source lang=arduino tabwidth=4:)
#include <Ethernet.h>

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

EthernetClient 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(;;)
;
}
}
(:sourceend:)

Share