Fork of mbed official TCPSocket_Helloworld using PicoTCP
Dependencies: PicoTCP lpc1768-picotcp-eth mbed-rtos mbed
Fork of TCPSocket_HelloWorld by
This is a fork of the official TCPSocket_Helloworld from mbed. (https://mbed.org/users/mbed_official/code/TCPSocket_HelloWorld/).
This project demonstrates that the PicoTCP library basically provides the same API calls, so in order to change the TCP/IP stack of your application, you only need to remove the EthernetInterface library and replace it with the following two projects:
main.cpp
- Committer:
- tass
- Date:
- 2013-07-03
- Revision:
- 15:e996dc0de6c5
- Parent:
- 11:59dcefdda506
File content as of revision 15:e996dc0de6c5:
#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) {} }