Dependencies:   EthernetInterface mbed-rtos mbed

Fork of TCPSocket_HelloWorld by mbed official

Files at this revision

API Documentation at this revision

Comitter:
jeremycai3721
Date:
Sun Sep 25 19:04:17 2016 +0000
Parent:
14:72be2b8b7f24
Commit message:
CodeShare

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed May 14 15:07:26 2014 +0000
+++ b/main.cpp	Sun Sep 25 19:04:17 2016 +0000
@@ -1,11 +1,12 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
+Serial pc(USBTX, USBRX);
 
 int main() {
     EthernetInterface eth;
     eth.init(); //Use DHCP
     eth.connect();
-    printf("IP Address is %s\n", eth.getIPAddress());
+    pc.printf("IP Address is %s\n", eth.getIPAddress());
     
     TCPSocketConnection sock;
     sock.connect("mbed.org", 80);
@@ -17,10 +18,14 @@
     int ret;
     while (true) {
         ret = sock.receive(buffer, sizeof(buffer)-1);
-        if (ret <= 0)
+        if (ret <= 0) {
+            pc.printf("I am here");
             break;
+            }
+            
+        
         buffer[ret] = '\0';
-        printf("Received %d chars from server:\n%s\n", ret, buffer);
+        pc.printf("Received %d chars from server:\n%s\n", ret, buffer);
     }
       
     sock.close();