Websocket Hello World over an ethernet network
Dependencies: EthernetNetIf mbed DNSResolver
main.cpp
- Committer:
- samux
- Date:
- 2011-11-15
- Revision:
- 6:aa2b63dc24f3
- Parent:
- 5:f34f1ae8de92
- Child:
- 7:ecad5b72fa16
File content as of revision 6:aa2b63dc24f3:
#include "mbed.h" #include "Websocket.h" Serial pc(USBTX, USBRX); 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"); int main() { while (1) { while(!ws.connect()) pc.printf("cannot connect websocket, retrying\r\n"); tmr.start(); while (1) { if(tmr.read() > 1) { //Here, we format the string we will be sending to the server //the format we are sending in is JSON ws.send("Hello World"); tmr.start(); } Net::poll(); } } }