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.
Revision 0:078749d5c10c, committed 2015-02-18
- Comitter:
- lzzcd001
- Date:
- Wed Feb 18 14:56:26 2015 +0000
- Commit message:
- HTTP client
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Feb 18 14:56:26 2015 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+int main() {
+ EthernetInterface eth;
+ eth.init(); //Use DHCP
+ eth.connect();
+ printf("IP Address is %s\n", eth.getIPAddress());
+
+ TCPSocketConnection sock;
+ sock.connect("mbed.org", 80);
+
+ char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
+ sock.send_all(http
+ _cmd, sizeof(http_cmd)-1);
+
+ char buffer[300];
+ int ret;
+ while (true) {
+ ret = sock.receive(buffer, sizeof(buffer)-1);
+ if (ret <= 0)
+ break;
+ buffer[ret] = '\0';
+ printf("Received %d chars from server:\n%s\n", ret, buffer);
+ }
+
+ sock.close();
+
+ eth.disconnect();
+
+ while(1) {}
+}
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Wed Feb 18 14:56:26 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/lzzcd001/code/mbed-rtos/#8c3d272b5f90
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Feb 18 14:56:26 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e188a91d3eaa \ No newline at end of file