Fork of mbed official TCPSocket_Helloworld using PicoTCP

Dependencies:   PicoTCP lpc1768-picotcp-eth mbed-rtos mbed

Fork of TCPSocket_HelloWorld by mbed official

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:

Files at this revision

API Documentation at this revision

Comitter:
emilmont
Date:
Fri Jul 27 13:59:39 2012 +0000
Parent:
8:2570d35b0c47
Child:
10:8aeafea0e859
Commit message:
Cleanup example

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Thu Jul 26 15:12:00 2012 +0000
+++ b/EthernetInterface.lib	Fri Jul 27 13:59:39 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#b7a3766f6253
+http://mbed.org/users/mbed_official/code/EthernetInterface/#9dce8f443bfd
--- a/main.cpp	Thu Jul 26 15:12:00 2012 +0000
+++ b/main.cpp	Fri Jul 27 13:59:39 2012 +0000
@@ -10,24 +10,22 @@
     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 http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
+    sock.send_all(http_cmd, sizeof(http_cmd));
     
-    char in_buf[256];
+    char buffer[300];
     int ret;
     while (true) {
-        ret = sock.receive(in_buf, 255, 100);
+        ret = sock.receive(buffer, sizeof(buffer)-1);
         if (ret <= 0)
             break;
-        
-        in_buf[ret] = '\0';
-        printf("Received %d chars from server: %s\n", ret, in_buf);
+        buffer[ret] = '\0';
+        printf("Received %d chars from server:\n%s\n", ret, buffer);
     }
       
     sock.close();
     
     eth.disconnect();
     
-    while(1) {
-    }
+    while(1) {}
 }