websocket client ethernet hello world example
Dependencies: WebSocketClient EthernetInterface mbed-rtos mbed
Websocket client hello world over ethernet
Revision 0:1b0dc7de9db7, committed 2012-08-10
- Comitter:
- samux
- Date:
- Fri Aug 10 11:15:53 2012 +0000
- Child:
- 1:1c1802ec42a2
- Commit message:
- hello world using the websocket client library (ethernet)
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Fri Aug 10 11:15:53 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/EthernetInterface/#0d9ae7845bfe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebSocketClient.lib Fri Aug 10 11:15:53 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/samux/code/WebSocketClient/#10b6eaafc2da
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Aug 10 11:15:53 2012 +0000
@@ -0,0 +1,26 @@
+#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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Fri Aug 10 11:15:53 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed-rtos/#70bd33086f56
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Aug 10 11:15:53 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6 \ No newline at end of file
Samuel Mokrani