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: EthernetInterface IAP mbed-rtos mbed
Fork of TCPSocket_HelloWorld by
Diff: main.cpp
- Revision:
- 9:4757a976148d
- Parent:
- 7:65188f4a8c25
- Child:
- 11:59dcefdda506
diff -r 2570d35b0c47 -r 4757a976148d main.cpp
--- a/main.cpp Thu Jul 26 15:12:00 2012 +0000
+++ b/main.cpp Fri Jul 27 13:59:39 2012 +0000
@@ -10,24 +10,22 @@
TCPSocketConnection sock;
sock.connect("mbed.org", 80);
- char http_cmd[] = "GET /media/uploads/donatien/hello.txt HTTP/1.1\r\nHost: %s\r\n\r\n";
- sock.send_all(http_cmd, sizeof(http_cmd) - 1, 3000);
+ char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
+ sock.send_all(http_cmd, sizeof(http_cmd));
- char in_buf[256];
+ char buffer[300];
int ret;
while (true) {
- ret = sock.receive(in_buf, 255, 100);
+ ret = sock.receive(buffer, sizeof(buffer)-1);
if (ret <= 0)
break;
-
- in_buf[ret] = '\0';
- printf("Received %d chars from server: %s\n", ret, in_buf);
+ buffer[ret] = '\0';
+ printf("Received %d chars from server:\n%s\n", ret, buffer);
}
sock.close();
eth.disconnect();
- while(1) {
- }
+ while(1) {}
}
