ap
Dependencies: DnsQuery
Dependents: WizFi310_TCP_Echo_Server_Example
Fork of NetworkSocketAPI by
Diff: TCPSocket.cpp
- Revision:
- 118:96627c4b83d5
- Parent:
- 117:ff83eb6a1ab9
- Child:
- 126:636a06d0aa42
diff -r ff83eb6a1ab9 -r 96627c4b83d5 TCPSocket.cpp --- a/TCPSocket.cpp Wed Apr 20 19:48:17 2016 -0500 +++ b/TCPSocket.cpp Wed Apr 20 20:38:00 2016 -0500 @@ -54,6 +54,10 @@ { mbed::Timer timer; timer.start(); + mbed::Timeout timeout; + if (_timeout >= 0) { + timeout.attach_us(&Socket::wakeup, _timeout * 1000); + } while (true) { if (!_socket) { @@ -62,7 +66,7 @@ int sent = _iface->socket_send(_socket, data, size); if (sent != NSAPI_ERROR_WOULD_BLOCK - || (_timeout >= 0 && timer.read_ms() > _timeout)) { + || (_timeout >= 0 && timer.read_ms() >= _timeout)) { return sent; } @@ -74,6 +78,10 @@ { mbed::Timer timer; timer.start(); + mbed::Timeout timeout; + if (_timeout >= 0) { + timeout.attach_us(&Socket::wakeup, _timeout * 1000); + } while (true) { if (!_socket) { @@ -82,7 +90,7 @@ int recv = _iface->socket_recv(_socket, data, size); if (recv != NSAPI_ERROR_WOULD_BLOCK - || (_timeout >= 0 && timer.read_ms() > _timeout)) { + || (_timeout >= 0 && timer.read_ms() >= _timeout)) { return recv; }