Hiroshi Yamaguchi / Mbed 2 deprecated SimpleSocketExamples 1.0

Dependencies:   EthernetNetIf SimpleSocket 1.0 mbed

Revision:
39:108499af2b53
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/udpreceiver.cpp	Wed Jun 06 03:34:16 2012 +0000
@@ -0,0 +1,20 @@
+#include "EthernetNetIf.h"
+#include "SimpleSocket.h"
+
+void udpreceiver() {
+    EthernetNetIf eth;
+    eth.setup();
+    
+    DatagramSocket datagram(7777);
+
+    Host buddy;
+    while (true) {
+        if (datagram.receive(&buddy, 1) > 0) {
+            IpAddr ip = buddy.getIp();
+            int port = buddy.getPort();
+            char buf[80] = {};
+            int len = datagram.read(buf, sizeof(buf) - 1);
+            printf("received from %d.%d.%d.%d:%d %s", ip[0],ip[1], ip[2], ip[3], port, buf);
+        }
+    }
+}
\ No newline at end of file