Creates a client which can connect to a server with specified internet IP address and port.
PhpocClient()
none
none
#include <Phpoc.h>
// hostname of web server:
char server_name[] = "example.phpoc.com";
PhpocClient client;
void setup() {
Serial.begin(9600);
while(!Serial)
;
Serial.println("Sending GET request to web server");
// initialize PHPoC [WiFi] Shield:
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
//Phpoc.begin();
// connect to web server on port 80:
if(client.connect(server_name, 80))
{
// if connected:
Serial.println("Connected to server");
// make a HTTP request:
//client.println("GET / HTTP/1.0");
client.println("GET /asciilogo.txt HTTP/1.0");
//client.println("GET /remote_addr/ HTTP/1.0");
client.println("Host: example.phpoc.com");
client.println();
}
else // if not connected:
Serial.println("connection failed");
}
void loop() {
if(client.available())
{
// if there is an incoming byte from the server, read them and print them to
// serial monitor:
char c = client.read();
Serial.print(c);
}
if(!client.connected())
{
// if the server's disconnected, stop the client:
Serial.println("disconnected");
client.stop();
// do nothing forevermore:
while(true)
;
}
}