Alternative TCPSocket example using an HTTP GET to read a short "helloworld" text web page using a different server
Fork of ARMs demo HTTP socket demo. ARM's server was redirected and the demo was no longer working. An alternative server was setup and the code was modified to display the web page text in addition to just "200 OK". Only works for a very short web page - buffer only 400 characters but RAM is running out on the LPC1768 in the demo! Data read from the web page is read and parsed to control the mbed's 4 LEDs for a basic IoT demo.
Revision 1:965d7fb768b6, committed 2017-02-17
- Comitter:
- sarahmarshy
- Date:
- Fri Feb 17 16:32:24 2017 +0000
- Parent:
- 0:6b383744246e
- Child:
- 2:50f1485931f1
- Commit message:
- Execute GET request on www.arm.com
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jan 19 11:46:10 2017 -0600 +++ b/main.cpp Fri Feb 17 16:32:24 2017 +0000 @@ -17,10 +17,10 @@ // Open a socket on the network interface, and create a TCP connection to mbed.org TCPSocket socket; socket.open(&net); - socket.connect("developer.mbed.org", 80); + socket.connect("www.arm.com", 80); // Send a simple http request - char sbuffer[] = "GET / HTTP/1.1\r\nHost: developer.mbed.org\r\n\r\n"; + char sbuffer[] = "GET / HTTP/1.1\r\nHost: www.arm.com\r\n\r\n"; int scount = socket.send(sbuffer, sizeof sbuffer); printf("sent %d [%.*s]\n", scount, strstr(sbuffer, "\r\n")-sbuffer, sbuffer);