This is a quick example of a simple HTTP client program using the network-socket API that is provided as a part of mbed-os. The program brings up an underlying network interface, and uses it to perform an HTTP transaction over a TCPSocket.

Revision:
12:2e7466eba9a3
Parent:
5:3e952c60d705
Child:
13:ed9e4aa00044
--- a/main.cpp	Mon Feb 27 17:30:06 2017 +0000
+++ b/main.cpp	Wed Mar 08 20:30:07 2017 +0000
@@ -19,12 +19,12 @@
     socket.open(&net);
     socket.connect("developer.mbed.org", 80);
 
-    // Send a simple http request
+    // Send an HTTP request
     char sbuffer[] = "GET / HTTP/1.1\r\nHost: developer.mbed.org\r\n\r\n";
     int scount = socket.send(sbuffer, sizeof sbuffer);
     printf("sent %d [%.*s]\n", scount, strstr(sbuffer, "\r\n")-sbuffer, sbuffer);
 
-    // Recieve a simple http response and print out the response line
+    // Receive an http response and print out the response line
     char rbuffer[64];
     int rcount = socket.recv(rbuffer, sizeof rbuffer);
     printf("recv %d [%.*s]\n", rcount, strstr(rbuffer, "\r\n")-rbuffer, rbuffer);