Websocket Hello World over an ethernet network
Dependencies: EthernetNetIf mbed DNSResolver
main.cpp
- Committer:
- samux
- Date:
- 2012-02-01
- Revision:
- 8:66a7e251b8c5
- Parent:
- 7:ecad5b72fa16
File content as of revision 8:66a7e251b8c5:
#include "mbed.h" #include "Websocket.h" Serial pc(USBTX, USBRX); Timer tmr; //Here, we create a Websocket instance in 'rw' (write) mode //on the 'samux' channel Websocket ws("ws://sockets.mbed.org/ws/samux/rw"); int main() { char recv[128]; while (1) { while (!ws.connect()) pc.printf("cannot connect websocket, retrying\r\n"); tmr.start(); while (1) { 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(); } } }