1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
libnng(3)
=========
:doctype: manpage
:manmanual: nng
:mansource: nng
:icons: font
:copyright: Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> \
Copyright 2018 Capitar IT Group BV <info@capitar.com> \
This software 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
----
libnng - nanomsg next generation library
SYNOPSIS
--------
*cc* ['flags'] 'files' *-lnng* ['libraries']
DESCRIPTION
-----------
The <<nng#,nng(7)>> library provides a common messaging framework
intended to solve common communication problems in distributed applications.
It provides a C language API.
Common Functions
~~~~~~~~~~~~~~~~
The following common functions exist in _libnng_.
[cols="1,4"]
|===
|<<nng_alloc#,nng_alloc(3)>>|allocate memory
|<<nng_dial#,nng_dial(3)>>|create and start a dialer
|<<nng_free#,nng_free(3)>>|free memory
|<<nng_strerror#,nng_strerror(3)>>|return an error description
|===
Socket Functions
~~~~~~~~~~~~~~~~
The following functions operate on sockets.
[cols="1,4"]
|===
|<<nng_close#,nng_close(3)>>|close a socket
|<<nng_closeall#,nng_closeall(3)>>|close all open sockets
|<<nng_dial#,nng_dial(3)>>|create and start a dialer
|<<nng_getopt#,nng_getopt(3)>>|get a socket option
|<<nng_listen#,nng_listen(3)>>|create and start a listener
|<<nng_recv#,nng_recv(3)>>|receive data
|<<nng_send#,nng_send(3)>>|send data
|<<nng_setopt#,nng_setopt(3)>>|set a socket option
|===
Message Functions
~~~~~~~~~~~~~~~~~
Applications desiring to use the richest part of _libnng_ will want to
use the message API, where a message structure is passed between functions.
This API provides the most power support for zero-copy.
Messages are divided into a header and body, where the body generally carries
user-payload and the header carries protocol specific header information.
Most applications will only interact with the body.
[cols="1,4"]
|===
|<<nng_msg_alloc#,nng_msg_alloc(3)>>|allocate a message
|<<nng_msg_body#,nng_msg_body(3)>>|return the message body
|<<nng_msg_free#,nng_msg_free(3)>>|free a message
|<<nng_msg_header#,nng_msg_header(3)>>|return the message header
|<<nng_msg_header_len#,nng_msg_header_len(3)>>|return the message header length
|<<nng_msg_len#,nng_msg_len(3)>>|return the message body length
|<<nng_msg_realloc#,nng_msg_realloc(3)>>|reallocate a message
|<<nng_recv_msg#,nng_recvmsg(3)>>|receive a message
|<<nng_sendmsg#,nng_sendmsg(3)>>|send a message
|===
Asynchronous Operations
~~~~~~~~~~~~~~~~~~~~~~~
Most applications will interact with _nng_ synchronously; that is that
functions such as <<nng_send#,nng_send()>> will block the calling
thread until the operation has completed.
NOTE: Synchronous operations which send messages may return before the
message has actually been received, or even transmitted. Instead, These
functions return as soon as the message was successfully queued for
delivery.
Asynchronous operations behave differently. These operations are
initiated by the calling thread, but control returns immediately to
the calling thread. When the operation is subsequently completed (regardless
of whether this was successful or not), then a user supplied function
("callback") is executed.
A context structure, called an _aio_, is allocated and associated for
each asynchronous operation. Only a single asynchronous operation may
be associated with an _aio_ at any time.
The following functions are used in the asynchronous model:
[cols="1,4"]
|===
|<<nng_aio_alloc#,nng_aio_alloc(3)>>|allocate asynchronous I/O context
|<<nng_aio_cancel#,nng_aio_cancel(3)>>|cancel asynchronous I/O operation
|<<nng_aio_free#,nng_aio_free(3)>>|free asynchronous I/O context
|<<nng_aio_get_msg#,nng_aio_get_msg(3)>>|get message from an asynchronous receive
|<<nng_aio_result#,nng_aio_result(3)>>|return result from asynchronous operation
|<<nng_aio_stop#,nng_aio_stop(3)>>|stop asynchronous I/O operation
|<<nng_aio_wait#,nng_aio_wait(3)>>|wait for an asynchronous I/O operation
|<<nng_aio_set_msg#,nng_aio_set_msg(3)>>|set message for an asynchronous send
|<<nng_aio_set_timeout#,nng_aio_set_timeout(3)>>|set timeout for an asynchronous send
|<<nng_recv_aio#,nng_recv_aio(3)>>|receive a message asynchronously
|<<nng_send_aio#,nng_send_aio(3)>>|send a message asynchronously
|===
Protocols
~~~~~~~~~
The following functions are used to construct a socket with a specific
protocol:
[cols="1,4"]
|===
| <<nng_bus#,nng_bus_open(3)>>|open a bus socket
| <<nng_pair#,nng_pair_open(3)>>|open a pair socket
| <<nng_pub#,nng_pub_open(3)>>|open a pub socket
| <<nng_rep#,nng_rep_open(3)>>|open a rep socket
| <<nng_req#,nng_req_open(3)>>|open a req socket
| <<nng_respondent#,nng_respondent_open(3)>>|open a respondent socket
| <<nng_sub#,nng_sub_open(3)>>|open a sub socket
| <<nng_surveyor#,nng_surveyor_open(3)>>|open a surveyor socket
|===
Transports
~~~~~~~~~~
The following functions are used to register a transport for use.
[cols="1,4"]
|===
| <<nng_inproc#,nng_inproc_register(3)>>|register inproc transport
| <<nng_ipc#,nng_ipc_register(3)>>|register IPC transport
| <<nng_tcp#,nng_tcp_register(3)>>|register TCP transport
| <<nng_tls#,nng_tls_register(3)>>|register TLS transport
| <<nng_ws#,nng_ws_register(3)>>|register WebSocket transport
| <<nng_wss#,nng_wss_register(3)>>|register WebSocket Secure transport
| <<nng_zerotier#,nng_zerotier_register(3)>>|register ZeroTier transport
|===
TLS Configuration Objects
~~~~~~~~~~~~~~~~~~~~~~~~
The following functions are used to manipulate TLS configuration objects.
[cols="1,4"]
|===
| <<nng_tls_config_auth_alloc#nng_tls_config_alloc(3)>>|allocate TLS configuration
| <<nng_tls_config_auth_mode#nng_tls_config_auth_mode(3)>>|set authentication mode
| <<nng_tls_config_ca_chain#,nng_tls_config_ca_chain(3)>>|set certificate authority chain
| <<nng_tls_config_own_cert#nng_tls_config_own)cert(3)>>|set own certificate and key
| <<nng_tls_config_free#,nng_tls_config_free(3)>>}free TLS configuration
| <<nng_tls_config_server_name#,nng_tls_config_server_name(3)>>|set remote server name
|===
SEE ALSO
--------
<<nng#,nng(7)>>,
<<nng_compat#,nng_compat(3)>>
COPYRIGHT
---------
Copyright 2018 mailto:info@staysail.tech[Staysail Systems, Inc.] +
Copyright 2018 mailto:info@capitar.com[Capitar IT Group BV]
This document is supplied under the terms of the
https://opensource.org/licenses/MIT[MIT License].
|