Custom and bugfix

Dependents:   HTTPClient_HelloWorld_WIZ820io NTPClient_HelloWorld_WIZ820io TinyHTTPServer_WIZ820io

Fork of WIZ820ioInterface by Norimasa Okamoto

Revision:
7:c0cd6680bcb7
Parent:
5:fb15c35d1e28
--- a/Socket/UDPSocket.cpp	Sun Dec 01 18:40:14 2013 +0000
+++ b/Socket/UDPSocket.cpp	Sun Feb 02 14:20:31 2014 +0000
@@ -18,6 +18,8 @@
 
 #include "UDPSocket.h"
 
+static int udp_local_port;
+
 UDPSocket::UDPSocket()
 {
 }
@@ -41,7 +43,12 @@
         }
     }
     // set local port
-    eth->sreg<uint16_t>(_sock_fd, Sn_PORT, port);
+    if (port != 0) {
+        eth->sreg<uint16_t>(_sock_fd, Sn_PORT, port);
+    } else {
+        udp_local_port++;
+        eth->sreg<uint16_t>(_sock_fd, Sn_PORT, udp_local_port);
+    }
     // set udp protocol
     eth->setProtocol(_sock_fd, UDP);
     eth->scmd(_sock_fd, OPEN);