aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-05-02 16:01:22 -0700
committerGarrett D'Amore <garrett@damore.org>2018-05-03 06:41:19 -0700
commit159dc95695515db767e208c41d5f44b334b71adc (patch)
tree5390251d939c33b1d274d0767861d2012673e258 /docs
parent649e5d5ca9a03cef766e944c7735aab50041c012 (diff)
downloadnng-159dc95695515db767e208c41d5f44b334b71adc.tar.gz
nng-159dc95695515db767e208c41d5f44b334b71adc.tar.bz2
nng-159dc95695515db767e208c41d5f44b334b71adc.zip
fixes #389 Need pipe notification callbacks
This adds a new pipe event notification API (callbacks called on either pipe add or remove), including both tests and docs. Also supporting APIs to get the socket or endpoint associated with a pipe are included (tested and documented as well.)
Diffstat (limited to 'docs')
-rw-r--r--docs/man/libnng.3.adoc4
-rw-r--r--docs/man/nng_pipe.5.adoc3
-rw-r--r--docs/man/nng_pipe_dialer.3.adoc46
-rw-r--r--docs/man/nng_pipe_listener.3.adoc46
-rw-r--r--docs/man/nng_pipe_notify.3.adoc71
-rw-r--r--docs/man/nng_pipe_socket.3.adoc45
6 files changed, 215 insertions, 0 deletions
diff --git a/docs/man/libnng.3.adoc b/docs/man/libnng.3.adoc
index 61ceacc7..1164b613 100644
--- a/docs/man/libnng.3.adoc
+++ b/docs/man/libnng.3.adoc
@@ -73,8 +73,12 @@ Listeners accept incoming connection requets, and dialers make them.
|<<nng_listener_setopt.3#,nng_listener_setopt()>>|set listener option
|<<nng_listener_start.3#,nng_listener_start()>>|start listener
|<<nng_pipe_close.3#,nng_pipe_close()>>|close pipe
+|<<nng_pipe_dialer.3#,nng_pipe_dialer()>>|return dialer that created pipe
|<<nng_pipe_getopt.3#,nng_pipe_getopt()>>|get pipe option
|<<nng_pipe_id.3#,nng_pipe_id()>>|get numeric pipe identifier
+|<<nng_pipe_listener.3#,nng_pipe_listener()>>|return listener that created pipe
+|<<nng_pipe_notify.3#,nng_pipe_notify())>>|register pipe notification callback
+|<<nng_pipe_socket.3#,nng_pipe_socket())>>|return owning socket for pipe
|===
=== Message Handling Functions
diff --git a/docs/man/nng_pipe.5.adoc b/docs/man/nng_pipe.5.adoc
index a777c0d0..cf11c047 100644
--- a/docs/man/nng_pipe.5.adoc
+++ b/docs/man/nng_pipe.5.adoc
@@ -69,7 +69,10 @@ nng_pipe p = NNG_PIPE_INITIALIZER;
<<nng_msg_get_pipe.3#,nng_msg_get_pipe(3)>>,
<<nng_pipe_close.3#,nng_pipe_close(3)>>,
<<nng_pipe_getopt.3#,nng_pipe_getopt(3)>>,
+<<nng_pipe_dialer.3#,nng_pipe_dialer(3)>>,
<<nng_pipe_id.3#,nng_pipe_id(3)>>,
+<<nng_pipe_listener.3#,nng_pipe_listener(3)>>,
+<<nng_pipe_socket.3#,nng_pipe_socket(3)>>,
<<nng_dialer.5#,nng_dialer(5)>>,
<<nng_listener.5#,nng_listener(5)>>,
<<nng_options.5#,nng_options(5)>>,
diff --git a/docs/man/nng_pipe_dialer.3.adoc b/docs/man/nng_pipe_dialer.3.adoc
new file mode 100644
index 00000000..476ab1be
--- /dev/null
+++ b/docs/man/nng_pipe_dialer.3.adoc
@@ -0,0 +1,46 @@
+= nng_pipe_dialer(3)
+//
+// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+//
+// This document is supplied under the terms of the MIT License, a
+// copy of which should be located in the distribution where this
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
+
+== NAME
+
+nng_pipe_dialer - return dialer that created pipe
+
+== SYNOPSIS
+
+[source, c]
+----
+#include <nng/nng.h>
+
+nng_dialer nng_pipe_dialer(nng_pipe p);
+----
+
+== DESCRIPTION
+
+The `nng_pipe_dialer()` function returns the `<<nng_dialer.5#,nng_dialer>>`
+that created the pipe _p_.
+If the pipe was not created by a dialer, then the returned value will
+have an identifier (`<<nng_dialer_id.3#,nng_dialer_id()>>`) of `-1`.
+
+== RETURN VALUES
+
+This function returns the dialer that created the pipe, unless it was
+not created by a dialer, in which case a value initialized with
+`NNG_DIALER_INITIALIZER` will be returned.
+
+== ERRORS
+
+None.
+
+== SEE ALSO
+
+<<nng_pipe.5#,nng_pipe(5)>>,
+<<nng_dialer.5#,nng_dialer(5)>>,
+<<nng.7#,nng(7)>>
diff --git a/docs/man/nng_pipe_listener.3.adoc b/docs/man/nng_pipe_listener.3.adoc
new file mode 100644
index 00000000..3b7db4d6
--- /dev/null
+++ b/docs/man/nng_pipe_listener.3.adoc
@@ -0,0 +1,46 @@
+= nng_pipe_listener(3)
+//
+// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+//
+// This document is supplied under the terms of the MIT License, a
+// copy of which should be located in the distribution where this
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
+
+== NAME
+
+nng_pipe_listener - return listener that created pipe
+
+== SYNOPSIS
+
+[source, c]
+----
+#include <nng/nng.h>
+
+nng_listener nng_pipe_listener(nng_pipe p);
+----
+
+== DESCRIPTION
+
+The `nng_pipe_listener()` function returns the `<<nng_listener.5#,nng_lisener>>`
+that created the pipe _p_.
+If the pipe was not created by a listener, then the returned value will
+have an identifier (`<<nng_listener_id.3#,nng_listener_id()>>`) of `-1`.
+
+== RETURN VALUES
+
+This function returns the listener that created the pipe, unless it was
+not created by a listener, in which case a value initialized with
+`NNG_LISTENER_INITIALIZER` will be returned.
+
+== ERRORS
+
+None.
+
+== SEE ALSO
+
+<<nng_pipe.5#,nng_pipe(5)>>,
+<<nng_listener.5#,nng_listener(5)>>,
+<<nng.7#,nng(7)>>
diff --git a/docs/man/nng_pipe_notify.3.adoc b/docs/man/nng_pipe_notify.3.adoc
new file mode 100644
index 00000000..34b640c8
--- /dev/null
+++ b/docs/man/nng_pipe_notify.3.adoc
@@ -0,0 +1,71 @@
+= nng_pipe_notify(3)
+//
+// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+//
+// This document is supplied under the terms of the MIT License, a
+// copy of which should be located in the distribution where this
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
+
+== NAME
+
+nng_pipe_notify - register pipe notification callback
+
+== SYNOPSIS
+
+[source, c]
+----
+#include <nng/nng.h>
+
+typedef enum {
+ NNG_PIPE_ADD,
+ NNG_PIPE_REM,
+} nng_pipe_action;
+
+typedef void (*nng_pipe_cb)(nng_pipe, nng_pipe_action, void *);
+
+int nng_pipe_notify(nng_socket s, nng_pipe_cb cb, void *arg);
+----
+
+== DESCRIPTION
+
+The `nng_pipe_notify()` function registers the callback function _cb_
+to be called whenever a <<nng_pipe.5#,pipe>> is added to or removed from the
+socket _s_.
+
+The function _cb_ will be called with the action `NNG_PIPE_ADD` just before
+a pipe is added to the socket (as a result of a connection being established).
+The final argument passed will be the argument _arg_ that was specified when
+the function was registered.
+
+The function _cb_ will also be called with the action `NNG_PIPE_REM` when
+the pipe is being removed from the socket for any reason.
+This will also use the same argument _arg_.
+
+NOTE: Only one callback can be registered for a given socket.
+Subsequent calls to `nng_pipe_notify()` on the same socket will overwrite
+any prior registration.
+
+TIP: The callback _cb_ may reject a pipe for any reason by simply closing
+it using `<<nng_pipe_close.3#,nng_pipe_close()>>`.
+This might be done, for example, if the remote peer is not authorized to
+access this session, based on values determined with the aid of
+`<<nng_pipe_getopt.3#,nng_pipe_getopt()>>`.
+
+== RETURN VALUES
+
+This function returns 0 on success, and non-zero otherwise.
+
+== ERRORS
+
+`NNG_ECLOSED`:: The socket _s_ does not refer to an open socket.
+
+== SEE ALSO
+
+<<nng_pipe_close.3#,nng_pipe_close(3)>>,
+<<nng_pipe_getopt.3#,nng_pipe_getopt(3)>>,
+<<nng_pipe.5#,nng_pipe(5)>>,
+<<nng_socket.5#,nng_socket(5)>>,
+<<nng.7#,nng(7)>>
diff --git a/docs/man/nng_pipe_socket.3.adoc b/docs/man/nng_pipe_socket.3.adoc
new file mode 100644
index 00000000..f2d02aa3
--- /dev/null
+++ b/docs/man/nng_pipe_socket.3.adoc
@@ -0,0 +1,45 @@
+= nng_pipe_socket(3)
+//
+// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+//
+// This document is supplied under the terms of the MIT License, a
+// copy of which should be located in the distribution where this
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
+
+== NAME
+
+nng_pipe_socket - return owning socket for pipe
+
+== SYNOPSIS
+
+[source, c]
+----
+#include <nng/nng.h>
+
+nng_socket nng_pipe_socket(nng_pipe p);
+----
+
+== DESCRIPTION
+
+The `nng_pipe_socket()` function returns the `<<nng_socket.5#,nng_socket>>`
+that owns the pipe _p_.
+
+NOTE: The returned socket may be closed or in the process of closing, in
+which case it will not be usable with other functions.
+
+== RETURN VALUES
+
+This function returns the socket that "`owns`" the pipe.
+
+== ERRORS
+
+None.
+
+== SEE ALSO
+
+<<nng_pipe.5#,nng_pipe(5)>>,
+<<nng_socket.5#,nng_socket(5)>>,
+<<nng.7#,nng(7)>>