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 mbed-rtos mbed
main.cpp
- Committer:
- emilmont
- Date:
- 2012-07-25
- Revision:
- 7:65188f4a8c25
- Parent:
- 5:01f6c3e112af
- Child:
- 9:4757a976148d
File content as of revision 7:65188f4a8c25:
#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/donatien/hello.txt HTTP/1.1\r\nHost: %s\r\n\r\n";
sock.send_all(http_cmd, sizeof(http_cmd) - 1, 3000);
char in_buf[256];
int ret;
while (true) {
ret = sock.receive(in_buf, 255, 100);
if (ret <= 0)
break;
in_buf[ret] = '\0';
printf("Received %d chars from server: %s\n", ret, in_buf);
}
sock.close();
eth.disconnect();
while(1) {
}
}