Reference.ClientConstructor History
Hide minor edits - Show changes to output
November 01, 2011, at 11:37 AM
by Scott Fitzgerald -
Changed lines 1-4 from:
[[Ethernet]] : ''EthernetClient'' class
!!EthernetClient()
to:
[[Ethernet]] : ''Client'' class
!!Client
Changed lines 7-66 from:
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:)
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
* [[EthernetClient | EthernetClient()]]
* [[ClientConnected | connected()]]
* [[ClientConnect | connect()]]
* [[ClientWrite | write()]]
* [[ClientPrint | print()]]
* [[ClientPrintln | println()]]
* [[ClientAvailable | available()]]
* [[ClientRead | read()]]
* [[ClientFlush | flush()]]
* [[ClientStop | stop()]]
November 01, 2011, at 08:15 AM
by Scott Fitzgerald -
Changed lines 24-25 from:
to:
(:source lang=arduino tabwidth=4:)
Changed lines 66-68 from:
to:
October 31, 2011, at 11:42 AM
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 11:35 AM
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:
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 10:02 AM
by Scott Fitzgerald -
Added line 22:
Added line 64:
September 02, 2008, at 04: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(;;)
;
}
}
@]