ap

Dependencies:   DnsQuery

Dependents:   WizFi310_TCP_Echo_Server_Example

Fork of NetworkSocketAPI by NetworkSocketAPI

Revision:
118:96627c4b83d5
Parent:
117:ff83eb6a1ab9
--- a/UDPSocket.cpp	Wed Apr 20 19:48:17 2016 -0500
+++ b/UDPSocket.cpp	Wed Apr 20 20:38:00 2016 -0500
@@ -45,6 +45,10 @@
 {
     mbed::Timer timer;
     timer.start();
+    mbed::Timeout timeout;
+    if (_timeout >= 0) {
+        timeout.attach_us(&Socket::wakeup, _timeout * 1000);
+    }
 
     while (true) {
         if (!_socket) {
@@ -53,7 +57,7 @@
     
         int sent = _iface->socket_sendto(_socket, address, data, size);
         if (sent != NSAPI_ERROR_WOULD_BLOCK
-            || (_timeout >= 0 && timer.read_ms() > _timeout)) {
+            || (_timeout >= 0 && timer.read_ms() >= _timeout)) {
             return sent;
         }
 
@@ -65,6 +69,10 @@
 {
     mbed::Timer timer;
     timer.start();
+    mbed::Timeout timeout;
+    if (_timeout >= 0) {
+        timeout.attach_us(&Socket::wakeup, _timeout * 1000);
+    }
 
     while (true) {
         if (!_socket) {
@@ -73,7 +81,7 @@
     
         int recv = _iface->socket_recvfrom(_socket, address, buffer, size);
         if (recv != NSAPI_ERROR_WOULD_BLOCK
-            || (_timeout >= 0 && timer.read_ms() > _timeout)) {
+            || (_timeout >= 0 && timer.read_ms() >= _timeout)) {
             return recv;
         }