This builds on TCPSocket_HelloWorld and others to read an in-coming buffer and then build and send a buffer. Very much work in progress
Dependencies: EthernetInterface mbed-rtos mbed
Fork of TCPSocket_HelloWorld by
Diff: main.cpp
- Revision:
- 12:cce8fa67de18
- Parent:
- 11:59dcefdda506
--- a/main.cpp Fri Aug 10 09:41:51 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -#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) {} -}