NetworkSocketAPI
Dependents: HelloWizFi250Interface
Fork of NetworkSocketAPI by
Revision 65:ca337f9ebdab, committed 2016-04-01
- Comitter:
- geky
- Date:
- Fri Apr 01 16:29:45 2016 +0000
- Parent:
- 64:c3dfac768d9d
- Child:
- 66:c84a4c76cb94
- Commit message:
- Added support for closing sockets during blocking recvs
Changed in this revision
Socket.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Socket.cpp Wed Mar 09 05:52:30 2016 +0000 +++ b/Socket.cpp Fri Apr 01 16:29:45 2016 +0000 @@ -69,12 +69,13 @@ if (!_socket) { return 0; } - - int32_t err = _socket->close(); + + SocketInterface *socket = _socket; + _socket = 0; + int32_t err = socket->close(); if (!err) { - _iface->destroySocket(_socket); - _socket = 0; + _iface->destroySocket(socket); } return err; @@ -90,11 +91,11 @@ int32_t Socket::recv(void *data, uint32_t size, bool blocking) { - if (!_socket) { - return NS_ERROR_NO_CONNECTION; - } - while (true) { + if (!_socket) { + return NS_ERROR_NO_CONNECTION; + } + int32_t recv = _socket->recv(data, size); if (recv != 0 || !blocking) {