Reference.ClientConstructor History

Show minor edits - Show changes to markup

November 01, 2011, at 04:37 PM by Scott Fitzgerald -
Changed lines 1-4 from:

Ethernet : EthernetClient class

EthernetClient()

to:

Ethernet : Client class

Client

Changed lines 7-66 from:
to:

Client is the base class for all Ethernet client based calls. It is not called directly, but invoked whenever you use a function that relies on it.

Functions

November 01, 2011, at 01:15 PM by Scott Fitzgerald -
Changed lines 24-25 from:
to:
Changed lines 66-68 from:
to:
October 31, 2011, at 04:42 PM by Scott Fitzgerald -
Changed lines 1-4 from:

Ethernet : Client class

Client()

to:

Ethernet : EthernetClient class

EthernetClient()

Changed lines 11-13 from:

Client(ip, port)
Client(URL, port)

to:

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

Changed lines 32-33 from:

Client client(server, 80);

to:

EthernetClient client(server, 80);

October 31, 2011, at 04:35 PM by Scott Fitzgerald -
Changed lines 7-8 from:

Creates a client which can connect to the specified internet IP address and port.

to:

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

Changed lines 11-12 from:

Client(ip, port)

to:

Client(ip, port)
Client(URL, port)

Added lines 18-19:

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

October 31, 2011, at 03:02 PM by Scott Fitzgerald -
Added line 22:
Added line 64:
September 02, 2008, at 10:36 PM by David A. Mellis -
Added lines 1-64:

Ethernet : Client class

Client()

Description

Creates a client which can connect to the specified internet IP address and port.

Syntax

Client(ip, port)

Parameters

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

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

Example

#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
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(;;)
      ;
  }
}

Share