Skip to content

Instantly share code, notes, and snippets.

@harrisonhjones
Last active September 23, 2015 06:31
Show Gist options
  • Save harrisonhjones/bbaa0bda3c5ae6e39ee5 to your computer and use it in GitHub Desktop.
Save harrisonhjones/bbaa0bda3c5ae6e39ee5 to your computer and use it in GitHub Desktop.
Particle IO - TCP Client Test
TCPClient client;
bool over = false;
void setup()
{
// Make sure your Serial Terminal app is closed before powering your device
Serial.begin(9600);
// Now open your Serial Terminal, and hit any key to continue!
while(!Serial.available()) SPARK_WLAN_Loop();
Serial.println("connecting... V1.2");
if (client.connect("119b1a62.ngrok.io", 80))
{
Serial.println("connected");
client.println("GET /hello HTTP/1.0");
client.println("Host: 119b1a62.ngrok.io");
client.println();
}
else
{
Serial.println("connection failed");
}
}
void loop()
{
if(over == false)
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
if (!client.connected())
{
Serial.println();
Serial.println("disconnecting.");
client.stop();
over = true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment