Ethernet interface for W5500 with bug fixed in socket::close()

Fork of EthernetInterfaceW5500 by W5500-Ethernet-Interface Makers

Revision:
9:615198a7b82b
Parent:
5:fb15c35d1e28
Child:
10:cadac6bcd169
--- a/Socket/UDPSocket.cpp	Sun Dec 15 12:29:47 2013 +0000
+++ b/Socket/UDPSocket.cpp	Mon Dec 23 13:51:35 2013 +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);