Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-http
Diff: source/main-https-socket-reuse.cpp
- Revision:
- 25:a8be9f3a530c
- Parent:
- 20:d851bc648f9e
- Child:
- 28:9bccd981a393
--- a/source/main-https-socket-reuse.cpp Wed Jan 03 11:26:52 2018 +0000
+++ b/source/main-https-socket-reuse.cpp Thu Jan 11 14:39:11 2018 +0100
@@ -55,10 +55,12 @@
mbedtls_printf("\nBody (%d bytes):\n\n%s\n", res->get_body_length(), res->get_body_as_string().c_str());
}
-void run() {
+int main() {
+ pc.baud(115200);
+
NetworkInterface* network = easy_connect(true);
if (!network) {
- return;
+ return 1;
}
// Create a TLS socket (which holds a TCPSocket)
@@ -68,7 +70,7 @@
socket->set_debug(true);
if (socket->connect() != 0) {
printf("TLS Connect failed %d\n", socket->error());
- return;
+ return 1;
}
// GET request to httpbin.org
@@ -79,7 +81,7 @@
HttpResponse* get_res = get_req->send();
if (!get_res) {
printf("HttpRequest failed (error code %d)\n", get_req->get_error());
- return;
+ return 1;
}
printf("\n----- HTTPS GET response -----\n");
dump_response(get_res);
@@ -98,7 +100,7 @@
HttpResponse* post_res = post_req->send(body, strlen(body));
if (!post_res) {
printf("HttpRequest failed (error code %d)\n", post_req->get_error());
- return;
+ return 1;
}
printf("\n----- HTTPS POST response -----\n");
@@ -112,13 +114,4 @@
Thread::wait(osWaitForever);
}
-int main() {
- pc.baud(115200);
-
- Thread t(osPriorityNormal, 8 * 1024);
- t.start(&run);
-
- Thread::wait(osWaitForever);
-}
-
#endif