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: Socket.cpp
- Revision:
- 20:dd5f19874adf
- Parent:
- 19:cad29ce6a01c
- Child:
- 21:65a9f84862f0
--- a/Socket.cpp Tue Apr 19 18:23:12 2016 -0500
+++ b/Socket.cpp Tue Apr 19 18:23:29 2016 -0500
@@ -35,6 +35,7 @@
{
_iface = iface;
_socket = _iface->socket_create(proto);
+ _iface->socket_attach(_socket, &Socket::thunk, this);
}
int Socket::close()
@@ -81,8 +82,15 @@
return _iface->socket_get_option(_socket, optname, optval, optlen);
}
-void Socket::thunk(void *p)
+void Socket::thunk(void *data)
{
- FunctionPointer *fptr = (FunctionPointer *)p;
- (*fptr)();
+ Socket *self = (Socket *)data;
+ if (self->_callback) {
+ self->_callback();
+ }
}
+
+void Socket::attach(FunctionPointer callback)
+{
+ _callback = callback;
+}