Websocket Hello World over an ethernet network
Dependencies: EthernetNetIf mbed DNSResolver
Revision 8:66a7e251b8c5, committed 2012-02-01
- Comitter:
- samux
- Date:
- Wed Feb 01 17:24:22 2012 +0000
- Parent:
- 7:ecad5b72fa16
- Commit message:
Changed in this revision
--- a/Websocket.lib Tue Nov 15 20:26:38 2011 +0000 +++ b/Websocket.lib Wed Feb 01 17:24:22 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/samux/code/Websocket/#2c4462ca74fa +http://mbed.org/users/samux/code/Websocket/#f4aac491ea26
--- a/Wifly.lib Tue Nov 15 20:26:38 2011 +0000 +++ b/Wifly.lib Wed Feb 01 17:24:22 2012 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/samux/code/Wifly/#f524a28790b1 +http://mbed.org/users/samux/code/Wifly/#56f3c4da1ea8
--- a/main.cpp Tue Nov 15 20:26:38 2011 +0000 +++ b/main.cpp Wed Feb 01 17:24:22 2012 +0000 @@ -5,20 +5,23 @@ Timer tmr; //Here, we create a Websocket instance in 'rw' (write) mode -//on the 'test' channel -Websocket ws("ws://sockets.mbed.org/ws/test/rw"); +//on the 'samux' channel +Websocket ws("ws://sockets.mbed.org/ws/samux/rw"); int main() { + char recv[128]; while (1) { - - while(!ws.connect()) + + while (!ws.connect()) pc.printf("cannot connect websocket, retrying\r\n"); - + tmr.start(); while (1) { - if(tmr.read() > 1) - { - ws.send("Hello World"); + if (tmr.read() > 0.5) { + ws.send("Hello World! over Ethernet"); + if (ws.read(recv)) { + pc.printf("recv: %s\r\n", recv); + } tmr.start(); } Net::poll();