Websocket Hello World over an ethernet network
Dependencies: EthernetNetIf mbed DNSResolver
Diff: main.cpp
- Revision:
- 8:66a7e251b8c5
- Parent:
- 7:ecad5b72fa16
--- 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();