s

Dependencies:   WebSocketClient

Fork of Websocket_Ethernet_HelloWorld by mbed_example

main.cpp

Committer:
samux
Date:
2012-08-10
Revision:
0:1b0dc7de9db7
Child:
1:1c1802ec42a2

File content as of revision 0:1b0dc7de9db7:

#include "mbed.h"
#include "EthernetInterface.h"
#include "Websocket.h"


int main() {
    char recv[30];

    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    printf("IP Address is %s\n\r", eth.getIPAddress());

    Websocket ws("ws://sockets.mbed.org:443/ws/demo/rw");
    ws.connect();

    while (1) {
        int res = ws.send("WebSocket Hello World!");

        if (ws.read(recv)) {
            printf("rcv: %s\r\n", recv);
        }

        wait(0.1);
    }
}