Example program with HTTPServer and sensor data streaming over TCPSockets, using Donatien Garnier's Net APIs and services code on top of LWIP. Files StreamServer.h and .cpp encapsulate streaming over TCPSockets. Broadcast is done by sendToAll(), and all incoming data is echoed back to the client. Echo code can be replaced with some remote control of the streaming interface. See main() that shows how to periodically send some data to all subscribed clients. To subscribe, a client should open a socket at <mbed_ip> port 123. I used few lines in TCL code to set up a quick sink for the data. HTTP files are served on port 80 concurrently to the streaming.

Dependencies:   mbed

Revision:
1:3ee499525aa5
Parent:
0:e614f7875b60
--- a/if/eth/EthernetNetIf.cpp	Sat Jun 12 06:01:50 2010 +0000
+++ b/if/eth/EthernetNetIf.cpp	Mon Jun 14 03:24:33 2010 +0000
@@ -76,21 +76,21 @@
   m_pNetIf->hwaddr_len = ETHARP_HWADDR_LEN; //6
   eth_address((char *)m_pNetIf->hwaddr);
   
-  DBG("\r\nHW Addr is : %02x:%02x:%02x:%02x:%02x:%02x.\r\n", 
+  DBG("HW Addr is : %02x:%02x:%02x:%02x:%02x:%02x.\r\n", 
   m_pNetIf->hwaddr[0], m_pNetIf->hwaddr[1], m_pNetIf->hwaddr[2],
   m_pNetIf->hwaddr[3], m_pNetIf->hwaddr[4], m_pNetIf->hwaddr[5]);
-  DBG("\r\nIn Setup.\r\n");
+  DBG("In Setup.\r\n");
   
   m_pNetIf = netif_add(m_pNetIf, &(m_ip.getStruct()), &(m_netmask.getStruct()), &(m_gateway.getStruct()), NULL, eth_init, ip_input);//ethernet_input);// ip_input);
   //m_pNetIf->hostname = "mbedDG";//(char *)m_hostname; //Not used for now
   netif_set_default(m_pNetIf);
   
-  //DBG("\r\nStarting DHCP.\r\n");
+  //DBG("Starting DHCP.\r\n");
   
   if(m_useDhcp)
   {
     dhcp_start(m_pNetIf);
-    DBG("\r\nDHCP Started, waiting for IP...\r\n");
+    DBG("DHCP Started, waiting for IP...\r\n");
   }
   else
   {
@@ -109,14 +109,14 @@
         dhcp_stop(m_pNetIf);
       else
         netif_set_down(m_pNetIf);
-      DBG("\r\nTimeout.\r\n");
+      DBG("Timeout.\r\n");
       return ETH_TIMEOUT;
     }
   }
   
   m_ip = IpAddr(&(m_pNetIf->ip_addr));
    
-  DBG("\r\nConnected, IP : %d.%d.%d.%d\r\n", m_ip[0], m_ip[1], m_ip[2], m_ip[3]);
+  DBG("Connected, IP : %d.%d.%d.%d\r\n", m_ip[0], m_ip[1], m_ip[2], m_ip[3]);
   
   return ETH_OK;
 }