websocket client ethernet hello world example

Dependencies:   WebSocketClient EthernetInterface mbed-rtos mbed

Websocket client hello world over ethernet

Committer:
samux
Date:
Thu Aug 23 14:11:49 2012 +0000
Revision:
2:00da1457c871
Parent:
1:1c1802ec42a2
update with the latest ws library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 1:1c1802ec42a2 1 #include "mbed.h"
samux 1:1c1802ec42a2 2 #include "EthernetInterface.h"
samux 1:1c1802ec42a2 3 #include "Websocket.h"
samux 1:1c1802ec42a2 4
samux 1:1c1802ec42a2 5
samux 1:1c1802ec42a2 6 int main() {
samux 1:1c1802ec42a2 7 char recv[30];
samux 1:1c1802ec42a2 8
samux 1:1c1802ec42a2 9 EthernetInterface eth;
samux 1:1c1802ec42a2 10 eth.init(); //Use DHCP
samux 1:1c1802ec42a2 11 eth.connect();
samux 1:1c1802ec42a2 12 printf("IP Address is %s\n\r", eth.getIPAddress());
samux 1:1c1802ec42a2 13
samux 1:1c1802ec42a2 14 Websocket ws("ws://sockets.mbed.org:443/ws/demo/wo");
samux 1:1c1802ec42a2 15 ws.connect();
samux 1:1c1802ec42a2 16
samux 1:1c1802ec42a2 17 while (1) {
samux 1:1c1802ec42a2 18 ws.send("WebSocket Hello World over Ethernet");
samux 1:1c1802ec42a2 19 wait(1.0);
samux 1:1c1802ec42a2 20 }
samux 1:1c1802ec42a2 21 }