NetworkSocketAPI

Dependencies:   DnsQuery

Dependents:   HelloWizFi250Interface

Fork of NetworkSocketAPI by NetworkSocketAPI

Revision:
92:dd5f19874adf
Parent:
91:cad29ce6a01c
Child:
93: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;
+}