From 98f23e10cc1d65da6a7f6c7e4f5665d7afc27a86 Mon Sep 17 00:00:00 2001
From: Garrett D'Amore <garrett@damore.org>
Date: Thu, 15 Mar 2018 08:40:17 -0700
Subject: fixes #286 nng_pair0_open (and all others) need man page fixes #279
 consider restructuring man sections

This represents a rather significant rework, and major editing
effort, for the entire set of manual pages.

All of the pages now have a section number in their filename;
this assists in some other tooling, particularly ebook generation
as every link needs to be programmatically modified when combined
into an ebook.

Section 5 is introduced, and populated with pages for the main
types, and all options are now documented.

Numerous errors have been corrected, including rewriting certain
portions such as the header section of the surveyor protocol.

Much work has been done to facilitate index generation, although
certainly more work remains here.

Every internal link within these pages now resolves; there are no
more dead links.  (This is required to generate Kindle format books.)
---
 docs/man/nng_pair.7.adoc | 132 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 132 insertions(+)
 create mode 100644 docs/man/nng_pair.7.adoc

(limited to 'docs/man/nng_pair.7.adoc')

diff --git a/docs/man/nng_pair.7.adoc b/docs/man/nng_pair.7.adoc
new file mode 100644
index 00000000..35f71187
--- /dev/null
+++ b/docs/man/nng_pair.7.adoc
@@ -0,0 +1,132 @@
+= nng_pair(7)
+//
+// 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_pair - pair protocol
+
+== SYNOPSIS
+
+.Version 0
+[source,c]
+----
+#include <nng/protocol/pair0/pair.h>
+
+int nng_pair0_open(nng_socket *s);
+----
+
+.Version 1
+[source,c]
+----
+#include <nng/protocol/pair1/pair.h>
+
+int nng_pair1_open(nng_socket *s);
+----
+
+== DESCRIPTION
+
+(((protocol, _pair_)))
+The ((_pair_ protocol)) implements a peer-to-peer pattern, where
+relationships between peers are one-to-one.
+
+Version 1 of this protocol supports an optional ((_polyamorous_ mode)) where a
+peer can maintain multiple partnerships.  Using this mode requires
+some additional sophistication in the application.
+
+=== Socket Operations
+
+The `nng_pair_open()` call creates a _pair_ socket.  Normally, this
+pattern will block when attempting to send a message, if no peer is
+able to receive the message.
+
+NOTE: Even though this mode may appear to be "reliable", because back-pressure
+prevents discarding messages most of the time, there are topologies involving
+_devices_ (see <<nng_device.3#,`nng_device()`>>) or raw mode sockets
+(see <<nng_options.5#NNG_OPT_RAW,`NNG_OPT_RAW`>>) where
+messages may be discarded.
+Applications that require reliable delivery semantics should consider using
+<<nng_req.7#,_req_>> sockets, or
+implement their own acknowledgement layer on top of _pair_ sockets.
+
+In order to avoid head-of-line blocking conditions, _polyamorous_ mode _pair_
+sockets (version 1 only) discard messages if they are unable to deliver them
+to a peer.
+
+=== Protocol Versions
+
+Version 0 is the legacy version of this protocol.
+It lacks any header
+information, and is suitable when building simple one-to-one topologies.
+
+TIP: Use version 0 if you need to communicate with other implementations,
+including the legacy https://github.com/nanomsg/nanomsg[nanomsg] library or
+https://github.com/go-mangos/mangos[mangos].
+
+Version 1 of the protocol offers improved protection against loops when
+used with <<nng_device.3#,`nng_device()`>>.
+It also offers _polyamorous_ mode for forming multiple partnerships
+on a single socket.
+
+NOTE: Version 1 of this protocol is considered experimental at this time.
+
+=== Polyamorous Mode
+
+Normally pair sockets are for one-to-one communication, and a given peer
+will reject new connections if it already has an active connection to another
+peer.
+
+In ((_polyamorous_ mode)), which is only available with version 1, a socket can
+support many one-to-one connections.
+In this mode, the application must
+choose the remote peer to receive an ougoing message by setting the
+<<nng_pipe.5#,`nng_pipe`>> to use for the outgoing message with
+the <<nng_msg_set_pipe.3#,`nng_msg_set_pipe()`>> function.
+
+Most often the value of the outgoing pipe will be obtained from an incoming
+message using the <<nng_msg_get_pipe.3#,`nng_msg_get_pipe()`>> function,
+such as when replying to an incoming message.
+
+In order to prevent head-of-line blocking, if the peer on the given pipe
+is not able to receive (or the pipe is no longer available, such as if the
+peer has disconnected), then the message will be discarded with no notification
+to the sender.
+
+=== Protocol Options
+
+The following protocol-specific options are available.
+
+((`NNG_OPT_PAIR1_POLY`))::
+
+   (Version 1 only).  This option enables the use of _polyamorous_ mode.
+   The value is read-write, and takes an integer boolean value.  The default
+   false value (0) indicates that legacy monogamous mode should be used.
+
+<<nng_options.5#NNG_OPT_MAXTTL,`NNG_OPT_MAXTTL`>>::
+
+   (Version 1 only).  Maximum time-to-live.
+
+=== Protocol Headers
+
+Version 0 of the pair protocol has no protocol-specific headers.
+
+Version 1 of the pair protocol uses a single 32-bit unsigned value.  The
+low-order (big-endian) byte of this value contains a "hop" count, and is
+used in conjuction with the
+<<nng_options.5#NNG_OPT_MAXTTL,`NNG_OPT_MAXTTL`>> option to guard against
+device forwarding loops.
+This value is initialized to 1, and incremented each time the message is
+received by a new node.
+    
+== SEE ALSO
+
+<<nng_pair_open.3#,nng_pair_open(3)>>,
+<<nng_options.5#,nng_options(5)>>,
+<<nng.7#,nng(7)>>
-- 
cgit v1.2.3-70-g09d2

