Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem WIZnetInterface mbed
Fork of UDPEchoServer by
Diff: main.cpp
- Revision:
- 1:3f409cd0bede
- Parent:
- 0:3e54841149df
- Child:
- 2:6b1012d93eb2
diff -r 3e54841149df -r 3f409cd0bede main.cpp
--- a/main.cpp	Thu Jul 26 15:00:24 2012 +0000
+++ b/main.cpp	Thu Jul 26 15:08:23 2012 +0000
@@ -1,1 +1,24 @@
 #include "mbed.h"
+#include "EthernetInterface.h"
+
+int main (void) {
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    printf("IP Address is %s\n", eth.getIPAddress());
+    
+    UDPSocket server;
+    server.bind(7);
+    
+    char buffer[256];
+    while (true) {
+        printf("\nWait for packet...\n");
+        
+        UDPPacket packet(buffer, sizeof(buffer));
+        int n = server.receiveFrom(packet);
+        
+        printf("Received packet from: %s\n", packet.get_address());
+        packet.set_data(buffer, n);
+        server.sendTo(packet);
+    }
+}
    