Simple code for comunication via TCP between the mbed and PC.

Dependencies:   EthernetInterface SimpleSocket mbed-rtos mbed

Fork of SimpleSocketExamples by Hiroshi Yamaguchi

Revision:
0:6dc3cfd058c6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/udpreceiver.cpp	Mon Feb 04 09:29:18 2013 +0000
@@ -0,0 +1,16 @@
+#include "SimpleSocket.h"
+
+void udpreceiver() {
+    DatagramSocket datagram(7777);
+    datagram.setTimeout(1.0);
+    Endpoint buddy;
+    while (true) {
+        if (datagram.receive(buddy) > 0) {
+            char *ip = buddy.get_address();
+            int port = buddy.get_port();
+            char buf[80] = {};
+            int len = datagram.read(buf, sizeof(buf) - 1);
+            printf("received from %s:%d %s", ip, port, buf);
+        }
+    }
+}
\ No newline at end of file