spark/core-firmware — pull request #186 by jacobrosenthal (2014-04-30 12:25:30+00:00)
Title: implement arduinos clienth and a few small changes to support it

Allows reuse of most existing client based code with VERY few changes. Selfishly I'm trying to port a websocket project I maintain called SkynetIM and I need this to avoid heavy alteration for Spark support.

Tested server with the note from this commit
https://github.com/spark/core-firmware/commit/0cd736d21c789524d86601779589693b3debe939

And client with the arduino ethernet example altered for spark below:

```cpp
#include "application.h"

// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] = "www.google.com"; // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

TCPClient client;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);

Serial.println("connecting...");

// 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.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("connection failed");
}
}

void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}

// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();

// do nothing forevermore:
while (true);
}
}
```