Example program for the Ethernet Shield V2.0 by SeeedStudio. The example gets an IP address via DHCP and then requests http://mbed.org/media/uploads/mbed_official/hello.txt

Dependencies:   WIZ820ioInterface mbed

Revision:
4:14045b8557cb
Parent:
3:2d0986d5542e
Child:
6:4bb23453ce91
--- a/main.cpp	Fri Apr 11 16:24:53 2014 +0000
+++ b/main.cpp	Mon Jun 09 13:23:14 2014 +0000
@@ -29,7 +29,7 @@
         s = eth.connect(); // Connect to network
 
         if (s == false || s < 0) {
-            printf(">>> Could not connect to network. Retrying!\n");
+            printf(">>> Could not connect to network! Retrying ...\n");
             wait(3);
         } else {
             break;
@@ -38,11 +38,16 @@
     printf(">>> Got IP address: %s\n", eth.getIPAddress());
 
     // Prepare the http request to mbed.org
+    printf(">>> Open socket to mbed.org:80\n");
     char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n";
     TCPSocketConnection sock;
-    sock.connect("mbed.org", 80);    
+    
+    while (sock.connect("mbed.org", 80) == -1) {
+        printf(">>> Unable to open socket! Retrying ...\n");
+    };
+    
+    printf(">>> Request %s\n", http_cmd);
     sock.send_all(http_cmd, sizeof(http_cmd)-1);
-    printf(">>> Sent request to mbed.org\n");
 
     // Read the response
     char buffer[300];
@@ -54,9 +59,13 @@
         buffer[ret] = '\0';
         printf(">>> Received %d chars from mbed.org:\n%s\n", ret, buffer);
     }
+
+    printf(">>> Close socket\n");
     sock.close();
     
     // Disconnect from network
+    printf(">>> Disconnect from network\n");
     eth.disconnect();
+
     return 0;
 }