NetworkSocketAPI

Dependencies:   DnsQuery

Dependents:   HelloWizFi250Interface

Fork of NetworkSocketAPI by NetworkSocketAPI

Files at this revision

API Documentation at this revision

Comitter:
Christopher Haster
Date:
Tue Apr 05 05:47:57 2016 -0500
Parent:
72:6a8b52ee83ed
Child:
74:ef2470ca328b
Commit message:
Added callbacks on potentially blocking operations

Changed in this revision

TCPServer.h Show annotated file Show diff for this revision Revisions of this file
TCPSocket.h Show annotated file Show diff for this revision Revisions of this file
UDPSocket.h Show annotated file Show diff for this revision Revisions of this file
--- a/TCPServer.h	Tue Apr 05 05:40:43 2016 -0500
+++ b/TCPServer.h	Tue Apr 05 05:47:57 2016 -0500
@@ -48,6 +48,12 @@
     \return         0 on success, negative on failure.
     */
     int accept(TCPSocket &connection);
+
+    /** Register a callback on when a new connection is ready
+    \param callback Function to call when accept will succeed, may be called in
+                    interrupt context.
+    */
+    void attach_accept(FuncPtr<void()> callback);
 };
 
 #endif
--- a/TCPSocket.h	Tue Apr 05 05:40:43 2016 -0500
+++ b/TCPSocket.h	Tue Apr 05 05:47:57 2016 -0500
@@ -56,7 +56,19 @@
     \param size     The maximum length of the buffer
     \return         Number of received bytes on success, negative on failure
      */
-    int receive(void *data, unsigned size);
+    int recv(void *data, unsigned size);
+
+    /** Register a callback on when send is ready
+    \param callback Function to call when send will succeed, may be called in
+                    interrupt context.
+    */
+    void attach_send(FuncPtr<void()> callback);
+
+    /** Register a callback on when recv is ready
+    \param callback Function to call when recv will succeed, may be called in
+                    interrupt context.
+    */
+    void attach_recv(FuncPtr<void()> callback);
 };
 
 #endif
--- a/UDPSocket.h	Tue Apr 05 05:40:43 2016 -0500
+++ b/UDPSocket.h	Tue Apr 05 05:47:57 2016 -0500
@@ -55,6 +55,18 @@
     \return the number of received bytes on success, negative on failure
     */
     int recvfrom(const char *addr, uint16_t port, void *buffer, unsigned size);
+
+    /** Register a callback on when send is ready
+    \param callback Function to call when send will succeed, may be called in
+                    interrupt context.
+    */
+    void attach_send(FuncPtr<void()> callback);
+
+    /** Register a callback on when recv is ready
+    \param callback Function to call when recv will succeed, may be called in
+                    interrupt context.
+    */
+    void attach_recv(FuncPtr<void()> callback);
 };
 
 #endif