Reference.WiFiClient History

Hide minor edits - Show changes to output

November 23, 2011, at 01:39 AM by Scott Fitzgerald -
Added lines 1-60:
[[WiFi]] : ''Client'' class

!!WiFiClient()

!!!!Description

Creates a client that can connect to to a specified internet IP address and port as defined in [[/Reference/WiFiClientConnect | client.connect()]].

!!!!Syntax

WiFiClient()

!!!!Parameters

none

!!!!Example

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

char ssid[] = "myNetwork"; // your network SSID (name)
char pass[] = "myPassword"; // your network password

int status = WL_IDLE_STATUS;
IPAddress server(74,125,115,105); // Google

// Initialize the client library
WiFiClient client;

void setup() {
Serial.begin(9600);
Serial.println("Attempting to connect to WPA network...");
Serial.print("SSID: ");
Serial.println(ssid);

status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
// don't do anything else:
while(true);
}
else {
Serial.println("Connected to wifi");
Serial.println("\nStarting connection...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
}
}

void loop() {

}
(:sourceend:)

Share