NetworkSocketAPI

Dependencies:   DnsQuery

Dependents:   HelloWizFi250Interface

Fork of NetworkSocketAPI by NetworkSocketAPI

Revision:
81:1600369a29dd
Parent:
80:9c6673c93082
Child:
82:97d166c4a193
--- a/UDPSocket.cpp	Tue Apr 05 12:02:56 2016 -0500
+++ b/UDPSocket.cpp	Tue Apr 05 12:52:07 2016 -0500
@@ -47,3 +47,35 @@
 
     return _iface->socket_recvfrom(_socket, address, buffer, size);
 }
+
+
+void UDPSocket::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 UDPSocket::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);
+    }
+}
+
+UDPSocket::~UDPSocket()
+{
+    if (_socket && _send_cb) {
+        _iface->socket_attach_send(_socket, 0, 0);
+    }
+
+    if (_socket && _recv_cb) {
+        _iface->socket_attach_recv(_socket, 0, 0);
+    }
+}