summaryrefslogtreecommitdiff
path: root/docs/man/nng_pipe.5.adoc
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-04-26 15:36:13 -0700
committerGarrett D'Amore <garrett@damore.org>2018-04-26 19:13:59 -0700
commitfd06aba05381055ab56e1ec81d56055b66462f0b (patch)
tree99633af36e1c393bffeda213c0ac85e83fc4a6ee /docs/man/nng_pipe.5.adoc
parent3de2b56557c80b310341c423492bd8ba895c1abe (diff)
downloadnng-fd06aba05381055ab56e1ec81d56055b66462f0b.tar.gz
nng-fd06aba05381055ab56e1ec81d56055b66462f0b.tar.bz2
nng-fd06aba05381055ab56e1ec81d56055b66462f0b.zip
fixes #375 integer types are error prone
This change converts the various integer types like nng_socket in the public API to opaque structures that are passed by value. Basically we just wrap the integer ID. This "hack" give us strong type checks by the compiler (yay!), at the expense of not being able to directly use these as numbers (so comparisions for example don't work, and neither does initialization to zero using the normal method. Comparison of disassembly output shows that at least with the optimizer enabled there is no difference in the compiler output between using a structure or an integral value.
Diffstat (limited to 'docs/man/nng_pipe.5.adoc')
-rw-r--r--docs/man/nng_pipe.5.adoc11
1 files changed, 8 insertions, 3 deletions
diff --git a/docs/man/nng_pipe.5.adoc b/docs/man/nng_pipe.5.adoc
index 4befd3e8..39247fbd 100644
--- a/docs/man/nng_pipe.5.adoc
+++ b/docs/man/nng_pipe.5.adoc
@@ -16,11 +16,11 @@ nng_pipe - communications pipe
== SYNOPSIS
[source, c]
------------
+----
#include <nng/nng.h>
-typedef uint32_t nng_pipe;
------------
+typedef struct nng_pipe_s nng_pipe;
+----
== DESCRIPTION
@@ -32,6 +32,11 @@ single TCP or IPC connection.)
Pipes are associated with either the listener or dialer that created them,
and therefore are also automatically associated with a single socket.
+IMPORTANT: The `nng_pipe` structure is always passed by value (both
+for input parameters and return values), and should be treated opaquely.
+Passing structures this way ensures gives the compiler a chance to perform
+accurate type checks in functions passing values of this type.
+
TIP: Most applications should never concern themselves with individual pipes.
However it is possible to access a pipe when more information about the
source of a message is needed, or when more control is required over