Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: TCPSocket.cpp
- Revision:
- 9:1600369a29dd
- Parent:
- 8:9c6673c93082
- Child:
- 10:97d166c4a193
diff -r 9c6673c93082 -r 1600369a29dd TCPSocket.cpp --- a/TCPSocket.cpp Tue Apr 05 12:02:56 2016 -0500 +++ b/TCPSocket.cpp Tue Apr 05 12:52:07 2016 -0500 @@ -62,3 +62,37 @@ return _iface->socket_recv(_socket, data, size); } + + +void TCPSocket::attach_send(mbed::FuncPtr<void()> callback) +{ + _send_cb = callback; + + if (_socket && _send_cb) { + return _iface->socket_attach_send(_socket, Socket::thunk, &_send_cb); + } else if (_socket) { + return _iface->socket_attach_send(_socket, 0, 0); + } +} + +void TCPSocket::attach_recv(mbed::FuncPtr<void()> callback) +{ + _recv_cb = callback; + + if (_socket && _recv_cb) { + return _iface->socket_attach_recv(_socket, Socket::thunk, &_recv_cb); + } else if (_socket) { + return _iface->socket_attach_recv(_socket, 0, 0); + } +} + +TCPSocket::~TCPSocket() +{ + if (_socket && _send_cb) { + _iface->socket_attach_send(_socket, 0, 0); + } + + if (_socket && _recv_cb) { + _iface->socket_attach_recv(_socket, 0, 0); + } +}