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:
- donatien
- Date:
- 2012-06-26
- Revision:
- 0:bb128f0e952f
- Child:
- 1:e2652bd064c6
File content as of revision 0:bb128f0e952f:
#include "mbed.h"
#include "EthernetInterface.h"
int main()
{
EthernetInterface eth;
eth.init(); //Use DHCP
eth.connect();
TCPSocket sock;
sock.connect("mbed.org", 80);
const char http_cmd[] = "GET /media/uploads/donatien/hello.txt HTTP/1.1\r\nHost: %s\r\n\r\n";
sock.send((std::uint8_t*)http_cmd, sizeof(http_cmd) - 1, 3000);
char in_buf[256];
bool firstIteration = true;
int ret;
do
{
ret = sock.receive((std::uint8_t*)in_buf, 255, firstIteration?3000:0);
in_buf[ret] = '\0';
printf("Received %d chars from server: %s\n", ret, in_buf);
firstIteration = false;
} while( ret > 0 );
sock.close();
eth.disconnect();
while(1) {
}
}