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/services/mysql/MySQLClient.cpp	Sat Jun 12 06:01:50 2010 +0000
+++ b/services/mysql/MySQLClient.cpp	Mon Jun 14 03:24:33 2010 +0000
@@ -196,18 +196,18 @@
   }
   else //Need to do a DNS Query...
   {
-    DBG("\r\nDNS Query...\r\n");
+    DBG("DNS Query...\r\n");
     m_pDnsReq = new DNSRequest();
     m_pDnsReq->setOnReply(this, &MySQLClient::onDNSReply);
     m_pDnsReq->resolve(&m_host);
-    DBG("\r\nMySQLClient : DNSRequest %p\r\n", m_pDnsReq);
+    DBG("MySQLClient : DNSRequest %p\r\n", m_pDnsReq);
   }
 }
 
 void MySQLClient::connect() //Start Connection
 {
   resetTimeout();
-  DBG("\r\nConnecting...\r\n");
+  DBG("Connecting...\r\n");
   m_pTCPSocket->connect(m_host);
   m_packetId = 0;
 }
@@ -442,11 +442,11 @@
 
 void MySQLClient::onTCPSocketEvent(TCPSocketEvent e)
 {
-  DBG("\r\nEvent %d in MySQLClient::onTCPSocketEvent()\r\n", e);
+  DBG("Event %d in MySQLClient::onTCPSocketEvent()\r\n", e);
 
   if(m_closed)
   {
-    DBG("\r\nWARN: Discarded\r\n");
+    DBG("WARN: Discarded\r\n");
     return;
   }
   
@@ -471,7 +471,7 @@
   case TCPSOCKET_CONRST:
   case TCPSOCKET_CONABRT:
   case TCPSOCKET_ERROR:
-    DBG("\r\nConnection error.\r\n");
+    DBG("Connection error.\r\n");
     onResult(MYSQL_CONN);
   case TCPSOCKET_DISCONNECTED:
     //There might still be some data available for reading
@@ -480,7 +480,7 @@
     {
       onResult(MYSQL_CONN);
     }
-    DBG("\r\nConnection closed by remote host.\r\n");
+    DBG("Connection closed by remote host.\r\n");
     break;
   }
 }
@@ -489,18 +489,18 @@
 {
   if(m_closed)
   {
-    DBG("\r\nWARN: Discarded\r\n");
+    DBG("WARN: Discarded\r\n");
     return;
   }
   
   if( r != DNS_FOUND )
   {
-    DBG("\r\nCould not resolve hostname.\r\n");
+    DBG("Could not resolve hostname.\r\n");
     onResult(MYSQL_DNS);
     return;
   }
   
-  DBG("\r\nDNS Resolved to %d.%d.%d.%d.\r\n",m_host.getIp()[0],m_host.getIp()[1],m_host.getIp()[2],m_host.getIp()[3]);
+  DBG("DNS Resolved to %d.%d.%d.%d.\r\n",m_host.getIp()[0],m_host.getIp()[1],m_host.getIp()[2],m_host.getIp()[3]);
   //If no error, m_host has been updated by m_pDnsReq so we're set to go !
   m_pDnsReq->close();
   delete m_pDnsReq;
@@ -521,7 +521,7 @@
 
 void MySQLClient::onTimeout() //Connection has timed out
 {
-  DBG("\r\nTimed out.\n");
+  DBG("Timed out.\n");
   onResult(MYSQL_DNS);
   close();
 }