Loading...

Reference.EthernetClient History

Hide minor edits - Show changes to markup

November 09, 2011, at 03:27 PM by Scott Fitzgerald -
Changed lines 28-29 from:

EthernetClient client();

to:

EthernetClient client;

November 09, 2011, at 03:19 PM by Scott Fitzgerald -
Changed lines 21-23 from:
to:
  1. 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 03: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 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 11:33 AM 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:)

  1. 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:)




Bookmark and Share