Dependencies:   EthernetNetIf mbed

Revision:
0:fcd581e3ad7d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jun 13 06:47:43 2011 +0000
@@ -0,0 +1,53 @@
+/*
+ * Echo server
+ * Listens on TCP and UDP ports 7 for any incoming connections
+ * Re-transmits any incoming bytes
+ */
+
+#include "mbed.h"
+#include "EthernetNetIf.h"
+
+#include "EchoServer.h"
+
+// Our Echo server
+EchoServer server;
+
+/*
+    Function: main
+    
+    Sets up the Ethernet interface using DHCP, reports the assigned
+    IP address via serial, binds the Echo server to port 7 on
+    TCP and UDP and then sits in a loop calling Net::poll() to
+    keep the network stack doing its thing
+*/
+int main() {
+    printf("\r\nSetting up...\r\n");
+    /*
+    //use DHCP
+    
+    // Our Ethernet interface
+    EthernetNetIf eth;
+    EthernetErr ethErr = eth.setup();
+    if (ethErr) {
+        printf("Error %d in setup.\n", ethErr);
+        return -1;
+    }
+    IpAddr ip = eth.getIp();
+    */
+    IpAddr ip(192,168,0,100);// = eth.getIp();
+    EthernetNetIf eth(ip,IpAddr(255,255,255,0),IpAddr(192,168,0,1),IpAddr(192,168,0,1));
+    EthernetErr ethErr = eth.setup();
+    if (ethErr) {
+        printf("Error %d in setup.\n", ethErr);
+        return -1;
+    }
+    
+    printf("mbed IP Address is %d.%d.%d.%d\r\n", ip[0], ip[1], ip[2], ip[3]);
+
+    server.bind(777,666);
+
+    printf("Entering while loop Net::poll()ing\r\n");
+    while (1) {
+        Net::poll();
+    }
+}