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/multicast.cpp	Mon Feb 04 09:29:18 2013 +0000
@@ -0,0 +1,24 @@
+#include "SimpleSocket.h"
+
+void multicast() {
+    Endpoint multicast;
+    multicast.set_address("239.192.1.100", 50000);
+    DatagramSocket datagram(multicast);
+    
+    while (true) {
+        Endpoint host;
+        datagram.setTimeout(1 + (rand() % 5) / 3.0);
+        if (datagram.receive(host) > 0) {
+            int value;
+            datagram.scanf("%d", &value);
+            char *ip = host.get_address();
+            printf("received from %s:%d %d\n", ip, host.get_port(), value);
+        } else {
+            char* message = "12345!";
+            datagram.printf(message);
+            datagram.send(multicast);
+            printf("sent: %s\n", message);
+            wait(1);
+        }
+    }
+}