Connects to an SSL server with specified IP address( or hostname) and port.
client.connectSSL(ip_addr, port)
client.connectSSL(hostname, port)
ip_addr - the IP address which the SSL client will connect to
port - the port number that the SSL client will connect to
hostname - the hostname that the SSL client will connect to
1 - on success
0 - on failure
#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 SSL web server");
// initialize PHPoC [WiFi] Shield:
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
//Phpoc.begin();
// connect to web server on port 443:
if(client.connectSSL(server_name, 443)) {
// 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();
}
}
void loop() {
// if there are incoming bytes available from the server, read them and print
// them:
while (client.available()) {
char c = client.read();
Serial.write(c);
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
// if the server's disconnected, stop the client:
Serial.println();
Serial.println("disconnecting from server.");
client.stop();
// do nothing forevermore:
while (true)
;
}
}