HofSpannung / Mbed 2 deprecated UDP_Server_WORKING

Dependencies:   mbed

Fork of UDP_V1_0 by HofSpannung

Revision:
1:be0485e31b72
Parent:
0:acad836c53e8
--- a/main.cpp	Tue Jun 05 12:26:56 2018 +0000
+++ b/main.cpp	Wed Jun 27 09:56:10 2018 +0000
@@ -1,5 +1,3 @@
-//code working
-
 #if !FEATURE_LWIP
     #error [NOT_SUPPORTED] LWIP not supported for this target
 #endif
@@ -26,17 +24,29 @@
                       "\r\n"                    \
                       HTTP_MESSAGE_BODY "\r\n"
 
+//EDIT Martin Zeitler
+//Definieren der Netzwerkparameter
+
+#define IPADDRESS "192.168.0.109"
+#define NETMASK "255.255.255.0"
+#define GATEWAY "192.168.0.1"
+#define PORT_RECEIVE 2223
+
+//EDIT END
+
 int main()
 {
     printf("Basic HTTP server example\n");
     
     EthernetInterface eth;
+    eth.set_network(IPADDRESS,NETMASK,GATEWAY);
     eth.connect();
     
+   
+    
     printf("The target IP address is '%s'\r\n", eth.get_ip_address());
     
     UDPSocket socket;
-    printf("Hello Succ\r\n");
     
     if(socket.open(&eth)!=0)
     {
@@ -44,16 +54,26 @@
         while(1);
     }
     
-    if(socket.bind(2223)!=0)
+    
+    //EDIT
+    //if(socket.bind(2223)!=0)
+    if(socket.bind(PORT_RECEIVE)!=0)
     {
         printf("Binding failed\r\n");
         while(1);
+    } 
+    else 
+    {
+        printf("Binding service on Port '%d' \n", PORT_RECEIVE);    
     }
-
+    //EDIT END
+    
+    
     char buf[256];
     SocketAddress sender;
-    printf("Before while...\r\n");
-    while (true) {
+    
+    while (true)
+    {
         int recBytes = socket.recvfrom(&sender,buf,256);
         printf("Received packet. Size: %d\r\n",recBytes);
         if(recBytes)