Simple HTTP server example with WIZ550io, W5500 (WIZnet chipset) .access the mbed via any browser, mbed echo back http request header.

Dependencies:   W5500Interface mbed

Fork of HTTPServer_echoback_WIZ550io by Bongjun Hur

Files at this revision

API Documentation at this revision

Comitter:
emilmont
Date:
Wed Jul 25 15:00:43 2012 +0000
Parent:
6:b011e8862694
Child:
8:2570d35b0c47
Commit message:
Update EthernetInterface

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	Mon Jul 23 11:53:08 2012 +0000
+++ b/EthernetInterface.lib	Wed Jul 25 15:00:43 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#cec293071eed
+http://mbed.org/users/mbed_official/code/EthernetInterface/#fd9597f1b81b
--- a/main.cpp	Mon Jul 23 11:53:08 2012 +0000
+++ b/main.cpp	Wed Jul 25 15:00:43 2012 +0000
@@ -1,34 +1,32 @@
 #include "mbed.h"
 #include "EthernetInterface.h"
 
-int main() 
-{
+int main() {
     EthernetInterface eth;
     eth.init(); //Use DHCP
     eth.connect();
     printf("IP Address is %s\n", eth.getIPAddress());
     
-    TCPSocket sock;
+    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(http_cmd, sizeof(http_cmd) - 1, 3000);
-
-    char in_buf[256];      
-    bool firstIteration = true;
+    sock.send_all(http_cmd, sizeof(http_cmd) - 1, 3000);
+    
+    char in_buf[256];
     int ret;
-    do
-    {
-        ret = sock.receive(in_buf, 255, firstIteration?3000:0);
+    while (true) {
+        ret = sock.receive(in_buf, 255, 100);
+        if (ret <= 0)
+            break;
+        
         in_buf[ret] = '\0';
-        
         printf("Received %d chars from server: %s\n", ret, in_buf);
-        firstIteration = false;
-    } while( ret > 0 );
+    }
       
-    sock.close();  
+    sock.close();
     
-    eth.disconnect();  
+    eth.disconnect();
     
     while(1) {
     }