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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
<!DOCTYPE HTML>
<html lang="en" class="light sidebar-visible" dir="ltr">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Migrating from NNG 1.x - NNG Reference Manual (DRAFT)</title>
<!-- Custom HTML head -->
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
<link rel="icon" href="../favicon.svg">
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="../fonts/fonts.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
<link rel="stylesheet" href="../theme/pagetoc.css">
<!-- Provide site root to javascript -->
<script>
var path_to_root = "../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
</script>
<!-- Start loading toc.js asap -->
<script src="../toc.js"></script>
</head>
<body>
<div id="body-container">
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
const html = document.documentElement;
html.classList.remove('light')
html.classList.add(theme);
html.classList.add("js");
</script>
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
<!-- Hide / unhide sidebar before it is displayed -->
<script>
var sidebar = null;
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
sidebar_toggle.checked = sidebar === 'visible';
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<!-- populated by js -->
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
<noscript>
<iframe class="sidebar-iframe-outer" src="../toc.html"></iframe>
</noscript>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
</div>
</nav>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</label>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">NNG Reference Manual (DRAFT)</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<style>
.mdbook-alerts {
padding: 8px 16px;
margin-bottom: 16px;
border-left: 0.25em solid var(--mdbook-alerts-color);
}
.mdbook-alerts > *:first-child {
margin-top: 0;
}
.mdbook-alerts > *:last-child {
margin-bottom: 0;
}
.mdbook-alerts-title {
display: flex;
font-weight: 600;
align-items: center;
line-height: 1;
color: var(--mdbook-alerts-color);
text-transform: capitalize;
}
.mdbook-alerts-icon {
display: inline-block;
width: 1em;
height: 1em;
margin-right: 0.2em;
background-color: currentColor;
-webkit-mask: no-repeat center / 100%;
mask: no-repeat center / 100%;
-webkit-mask-image: var(--mdbook-alerts-icon);
mask-image: var(--mdbook-alerts-icon);
}
.mdbook-alerts-note {
--mdbook-alerts-color: rgb(9, 105, 218);
/* https://icon-sets.iconify.design/material-symbols/info-outline-rounded/ */
--mdbook-alerts-icon: url('data:image/svg+xml,%3Csvg xmlns="http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg" width="24" height="24" viewBox="0 0 24 24"%3E%3Cpath fill="currentColor" d="M12 17q.425 0 .713-.288T13 16v-4q0-.425-.288-.712T12 11q-.425 0-.712.288T11 12v4q0 .425.288.713T12 17m0-8q.425 0 .713-.288T13 8q0-.425-.288-.712T12 7q-.425 0-.712.288T11 8q0 .425.288.713T12 9m0 13q-2.075 0-3.9-.788t-3.175-2.137q-1.35-1.35-2.137-3.175T2 12q0-2.075.788-3.9t2.137-3.175q1.35-1.35 3.175-2.137T12 2q2.075 0 3.9.788t3.175 2.137q1.35 1.35 2.138 3.175T22 12q0 2.075-.788 3.9t-2.137 3.175q-1.35 1.35-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12q0-3.35-2.325-5.675T12 4Q8.65 4 6.325 6.325T4 12q0 3.35 2.325 5.675T12 20m0-8"%2F%3E%3C%2Fsvg%3E');
}
.mdbook-alerts-tip {
--mdbook-alerts-color: rgb(26, 127, 55);
/* https://icon-sets.iconify.design/material-symbols/lightbulb-outline-rounded/ */
--mdbook-alerts-icon: url('data:image/svg+xml,%3Csvg xmlns="http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg" width="24" height="24" viewBox="0 0 24 24"%3E%3Cpath fill="currentColor" d="M12 22q-.825 0-1.412-.587T10 20h4q0 .825-.587 1.413T12 22m-3-3q-.425 0-.712-.288T8 18q0-.425.288-.712T9 17h6q.425 0 .713.288T16 18q0 .425-.288.713T15 19zm-.75-3q-1.725-1.025-2.738-2.75T4.5 9.5q0-3.125 2.188-5.312T12 2q3.125 0 5.313 2.188T19.5 9.5q0 2.025-1.012 3.75T15.75 16zm.6-2h6.3q1.125-.8 1.738-1.975T17.5 9.5q0-2.3-1.6-3.9T12 4Q9.7 4 8.1 5.6T6.5 9.5q0 1.35.613 2.525T8.85 14M12 14"%2F%3E%3C%2Fsvg%3E');
}
.mdbook-alerts-important {
--mdbook-alerts-color: rgb(130, 80, 223);
/* https://icon-sets.iconify.design/material-symbols/chat-info-outline-rounded/ */
--mdbook-alerts-icon: url('data:image/svg+xml,%3Csvg xmlns="http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg" width="24" height="24" viewBox="0 0 24 24"%3E%3Cpath fill="currentColor" d="M12 7q.425 0 .713-.288T13 6q0-.425-.288-.712T12 5q-.425 0-.712.288T11 6q0 .425.288.713T12 7m0 8q.425 0 .713-.288T13 14v-4q0-.425-.288-.712T12 9q-.425 0-.712.288T11 10v4q0 .425.288.713T12 15m-6 3l-2.3 2.3q-.475.475-1.088.213T2 19.575V4q0-.825.588-1.412T4 2h16q.825 0 1.413.588T22 4v12q0 .825-.587 1.413T20 18zm-.85-2H20V4H4v13.125zM4 16V4z"%2F%3E%3C%2Fsvg%3E');
}
.mdbook-alerts-warning {
--mdbook-alerts-color: rgb(154, 103, 0);
/* https://icon-sets.iconify.design/material-symbols/warning-outline-rounded/ */
--mdbook-alerts-icon: url('data:image/svg+xml,%3Csvg xmlns="http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg" width="24" height="24" viewBox="0 0 24 24"%3E%3Cpath fill="currentColor" d="M2.725 21q-.275 0-.5-.137t-.35-.363q-.125-.225-.137-.488t.137-.512l9.25-16q.15-.25.388-.375T12 3q.25 0 .488.125t.387.375l9.25 16q.15.25.138.513t-.138.487q-.125.225-.35.363t-.5.137zm1.725-2h15.1L12 6zM12 18q.425 0 .713-.288T13 17q0-.425-.288-.712T12 16q-.425 0-.712.288T11 17q0 .425.288.713T12 18m0-3q.425 0 .713-.288T13 14v-3q0-.425-.288-.712T12 10q-.425 0-.712.288T11 11v3q0 .425.288.713T12 15m0-2.5"%2F%3E%3C%2Fsvg%3E');
}
.mdbook-alerts-caution {
--mdbook-alerts-color: rgb(207, 34, 46);
/* https://icon-sets.iconify.design/material-symbols/brightness-alert-outline-rounded/ */
--mdbook-alerts-icon: url('data:image/svg+xml,%3Csvg xmlns="http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg" width="24" height="24" viewBox="0 0 24 24"%3E%3Cpath fill="currentColor" d="M12 17q.425 0 .713-.288T13 16q0-.425-.288-.712T12 15q-.425 0-.712.288T11 16q0 .425.288.713T12 17m0-4q.425 0 .713-.288T13 12V8q0-.425-.288-.712T12 7q-.425 0-.712.288T11 8v4q0 .425.288.713T12 13m-3.35 7H6q-.825 0-1.412-.587T4 18v-2.65L2.075 13.4q-.275-.3-.425-.662T1.5 12q0-.375.15-.737t.425-.663L4 8.65V6q0-.825.588-1.412T6 4h2.65l1.95-1.925q.3-.275.663-.425T12 1.5q.375 0 .738.15t.662.425L15.35 4H18q.825 0 1.413.588T20 6v2.65l1.925 1.95q.275.3.425.663t.15.737q0 .375-.15.738t-.425.662L20 15.35V18q0 .825-.587 1.413T18 20h-2.65l-1.95 1.925q-.3.275-.662.425T12 22.5q-.375 0-.737-.15t-.663-.425zm.85-2l2.5 2.5l2.5-2.5H18v-3.5l2.5-2.5L18 9.5V6h-3.5L12 3.5L9.5 6H6v3.5L3.5 12L6 14.5V18zm2.5-6"%2F%3E%3C%2Fsvg%3E');
}
</style>
<h1 id="migrating-from-nng-1x"><a class="header" href="#migrating-from-nng-1x">Migrating from NNG 1.x</a></h1>
<p>There are some incompatibities from NNG 1.x, and applications must make certain changes for NNG 2.0.
This guide should help with this migration.</p>
<h2 id="nanomsg-compatibility"><a class="header" href="#nanomsg-compatibility">Nanomsg Compatibility</a></h2>
<p>Applications using the legacy <code>libnanomsg</code> API will have to be updated to native <em>NNG</em> interfaces.
See the <a href="nanomsg.html">Migrating From libnanomsg</a> chapter for details.</p>
<h2 id="library-initialization"><a class="header" href="#library-initialization">Library Initialization</a></h2>
<p>It is now required for applications to initialize the library explicitly before using it.
This is done using the <a href="/api/init.html#initialization"><code>nng_init</code></a> function.</p>
<h2 id="renamed-functions"><a class="header" href="#renamed-functions">Renamed Functions</a></h2>
<p>The <code>nng_close</code> function has been renamed to <a href="/api/sock.html#closing-a-socket"><code>nng_socket_close</code></a> to make it clearer that
the object being closed is a socket. A compatible <code>nng_close</code> macro is available by defining <code>NNG1_TRANSITION</code>
in your compilation environment.</p>
<h2 id="new-aio-error-code-nng_estopped"><a class="header" href="#new-aio-error-code-nng_estopped">New AIO Error Code NNG_ESTOPPED</a></h2>
<p>When an operation fails with <a href="/api/errors.html#NNG_ESTOPPED"><code>NNG_ESTOPPED</code></a>, it means that the associated [<code>nni_aio</code>] object has
been permanently stopped and must not be reused. Applications must watch for this error code, and
not resubmit an operation that returns it. This is particularly important for callbacks that automatically
resubmit operations. Failure to observe this rule will lead to an infinite loop
as any further operations on the object will fail immediately with <code>NNG_ESTOPPED</code>.</p>
<h2 id="aio-provider-api-changes"><a class="header" href="#aio-provider-api-changes">AIO Provider API changes</a></h2>
<p>The API used for providers for asynchronous I/O operations has changed slightly.</p>
<ul>
<li>The <code>nng_aio_begin</code> function is removed. However a new <a href="/TODO.html"><code>nng_aio_reset</code></a> function should be called
instead, before performing any other operations on an <em>aio</em> object. (This simply clears certain fields.)</li>
<li>The <code>nng_aio_defer</code> function is replaced, with a very <a href="/TODO.html"><code>nng_aio_start</code></a> function. However, this function
has slightly different semantics. It will automatically call the callback if the operation cannot be
scheduled.</li>
<li>Be aware of the new <code>NNG_ESTOPPED</code> error code, for operations on a handle that is being torn down by
the consumer.</li>
</ul>
<h2 id="transport-specific-functions"><a class="header" href="#transport-specific-functions">Transport Specific Functions</a></h2>
<p>Transports have not needed to be registered for a long time now,
and the functions for doing so have been removed. These functions
can be simply removed from your application:</p>
<ul>
<li><code>nng_inproc_register</code></li>
<li><code>nng_ipc_register</code></li>
<li><code>nng_tls_register</code></li>
<li><code>nng_tcp_register</code></li>
<li><code>nng_ws_register</code></li>
<li><code>nng_wss_register</code></li>
<li><code>nng_zt_register</code></li>
</ul>
<p>Additionally, the header files containing these functions have been removed, such as
<code>nng/transport/ipc/ipc.h</code>. Simply remove <code>#include</code> references to those files.</p>
<p>The <code>NNG_OPT_WSS_REQUEST_HEADERS</code> and <code>NNG_OPT_WSS_RESPONSE_HEADERS</code> aliases for
<code>NNG_OPT_WS_OPT_WS_REQUEST_HEADERS</code> and <code>NNG_OPT_WS_RESPONSE_HEADERS</code> have been removed.
Just convert any use of them to <code>NNG_OPT_WS_REQUEST_HEADERS</code> or
<code>NNG_OPT_WS_RESPONSE_HEADERS</code> as appropriate.</p>
<h2 id="tls-configuration"><a class="header" href="#tls-configuration">TLS Configuration</a></h2>
<p>The support for configuring TLS via <code>NNG_OPT_TLS_CONFIG</code>, <code>NNG_TLS_AUTH_MODE</code>, <code>NNG_OPT_TLS_CA_FILE</code>,
<code>NNG_OPT_TLS_SERVER_NAME</code>, and similar has been removed.</p>
<p>Instead configuration must be performed by allocating
a <code>nng_tls_config</code> object, and then setting fields on it using the appropriate functions,
after which it may be configured on a listener or dialer using the <a href="/TODO.html"><code>nng_listener_set_tls</code></a>
or <a href="/TODO.html"><code>nng_dialer_set_tls</code></a> functions.</p>
<p>Likewise, when using the streams API, use the <a href="/TODO.html"><code>nng_stream_listener_set_tls</code></a> or
<a href="/TODO.html"><code>nng_stream_dialer_set_tls</code></a> functions.</p>
<p>Note that the declarations needed for TLS configuration are now available in <code><nng/nng.h></code>,
rather than the supplemental header.</p>
<h2 id="old-tls-versions-removed"><a class="header" href="#old-tls-versions-removed">Old TLS Versions Removed</a></h2>
<p>Support for very old TLS versions 1.0 and 1.1 is removed.
Further, the <code>NNG_TLS_1_0</code> and <code>NNG_TLS_1_1</code> constants are also removed.
Applications should use <code>NNG_TLS_1_2</code> or even <code>NNG_TLS_1_3</code> instead.</p>
<h2 id="only-one-tls-keycert-per-configuration"><a class="header" href="#only-one-tls-keycert-per-configuration">Only One TLS Key/Cert Per Configuration</a></h2>
<p>The ability to configure multiple keys and certificates for a given TLS configuration object is removed.
(The <a href="/TODO.html"><code>nng_tls_config_own_cert</code></a> will return <a href="/api/errors.html#NNG_EBUSY"><code>NNG_EBUSY</code></a> if it has already been called for the configuration.)
The intended purpose was to support alternative cryptographic algorithms, but this is not necessary, was never
used, and was error prone.</p>
<h2 id="support-for-local-addresses-in-dial-urls-removed"><a class="header" href="#support-for-local-addresses-in-dial-urls-removed">Support for Local Addresses in Dial URLs Removed</a></h2>
<p>NNG 1.x had an undocumented ability to specify the local address to bind
to when dialing, by using the local address in front of the destination
address separated by a semicolon. This was provided for legacy libnanomsg
compatilibility, and is no longer offered. The correct way to specify a
local address is by setting <code>NNG_OPT_LOCADDR</code> on the dialer.</p>
<h2 id="option-functions"><a class="header" href="#option-functions">Option Functions</a></h2>
<p>The previously deprecated <code>nng_pipe_getopt_xxx</code> family of functions is removed.
Applications should use <code>nng_pipe_get</code> and related functions instead.</p>
<p>The socket option function families for <code>nng_getopt</code> and <code>nng_setopt</code> have been removed as well.
In this case, use the <code>nng_socket_get</code> and <code>nng_socket_set</code> functions as appropriate.</p>
<p>The <code>_getopt</code> and <code>_setopt</code> functions for contexts, listeners, and dialers are no longer
present. Simply changing <code>_getopt</code> to <code>_get</code> or <code>_setopt</code> to <code>_set</code> in the function name
should be sufficient in most cases.</p>
<p>The following functions served no useful purpose (after other changes described in this document),
and are thus removed:</p>
<ul>
<li><code>nng_ctx_get_string</code></li>
<li><code>nng_ctx_set_string</code></li>
<li><code>nng_dialer_get_ptr</code></li>
<li><code>nng_dialer_set_ptr</code></li>
<li><code>nng_listener_get_ptr</code></li>
<li><code>nng_listener_set_ptr</code></li>
<li><code>nng_socket_get_ptr</code></li>
<li><code>nng_socket_set_ptr</code></li>
<li><code>nng_socket_get_string</code></li>
<li><code>nng_socket_set_string</code></li>
<li><code>nng_stream_get_ptr</code></li>
<li><code>nng_stream_set_ptr</code></li>
<li><code>nng_stream_dialer_get_ptr</code></li>
<li><code>nng_stream_dialer_set_ptr</code></li>
<li><code>nng_stream_listener_get_ptr</code></li>
<li><code>nng_stream_listener_set_ptr</code></li>
<li><code>nng_ctx_get_ptr</code> (not documented)</li>
<li><code>nng_ctx_set_ptr</code> (not documented)</li>
</ul>
<h2 id="untyped-option-functions-removed"><a class="header" href="#untyped-option-functions-removed">Untyped Option Functions Removed</a></h2>
<p>The following functions are removed. To access options, use a proper typed access function,
such as one ending in a suffix like <code>_bool</code> (to access a <code>bool</code> typed option).</p>
<ul>
<li><code>nng_ctx_get</code></li>
<li><code>nng_ctx_set</code></li>
<li><code>nng_dialer_get</code></li>
<li><code>nng_dialer_set</code></li>
<li><code>nng_listener_get</code></li>
<li><code>nng_listener_set</code></li>
<li><code>nng_pipe_get</code></li>
<li><code>nng_socket_get</code></li>
<li><code>nng_socket_set</code></li>
<li><code>nng_stream_get</code></li>
<li><code>nng_stream_set</code></li>
<li><code>nng_stream_dialer_get</code></li>
<li><code>nng_stream_dialer_set</code></li>
<li><code>nng_stream_listener_get</code></li>
<li><code>nng_stream_listener_set</code></li>
</ul>
<h2 id="stream-options"><a class="header" href="#stream-options">Stream Options</a></h2>
<p>The ability to set options on streams after they have been created is no longer present.
(It turns out that this was not very useful.) All functions <code>nng_stream_set_xxx</code> are removed.
For tuning the <code>NNG_OPT_TCP_NODELAY</code> or similar properties, set the option on the listener
or dialer that creates the stream instead.</p>
<h2 id="transport-options"><a class="header" href="#transport-options">Transport Options</a></h2>
<p>A number of transport options can no longer be set on the socket. Instead these
options must be set on the endpoint (dialer or listener) using the appropriate
<code>nng_dialer_set</code> or <code>nng_listener_set</code> option. This likely means that it is necessary
to allocate and configure the endpoint before attaching it to the socket. This will
also afford a much more fine-grained level of control over transport options.</p>
<p>The following options are copied from the socket when creating a dialer or listener,
but afterwards will not be changed on the dialer or listener if the socket
changes. It is recommended to set them properly on the socket before
creating dialers or listeners, or set them explicitly on the dialer or listener
directly:</p>
<ul>
<li><code>NNG_OPT_RECONNMINT</code></li>
<li><code>NNG_OPT_RECONNMAXT</code></li>
<li><code>NNG_OPT_RECVMAXSZ</code></li>
</ul>
<p>The latter option is a hint for transports and intended to facilitate early
detection (and possibly avoidance of extra allocations) of oversize messages,
before bringing them into the socket itself.</p>
<h2 id="socket-options"><a class="header" href="#socket-options">Socket Options</a></h2>
<p>The <code>NNG_OPT_PROTO</code>, <code>NNG_OPT_PROTONAME</code>, <code>NNG_OPT_PEER</code>, and <code>NNG_OPT_PEERNAME</code> options
have been replaced by functions instead of options.
Use <a href="/api/sock.html#socket-identity"><code>nng_socket_proto_id</code></a>, <a href="/api/sock.html#socket-identity"><code>nng_socket_peer_id</code></a>, <a href="/api/sock.html#socket-identity"><code>nng_socket_proto_name</code></a>, and <a href="/api/sock.html#socket-identity"><code>nng_socket_peer_name</code></a> instead.
Note that the new functions provide a reference to a static string, and thus do not require
allocation, and the returned strings should not be freed. Also the IDs are provided as <code>uint16_t</code>,
matching the actual wire protocol values, instead of <code>int</code>.</p>
<p>The <code>NNG_OPT_RAW</code> option has aso been replaced by a function, <a href="/api/sock.html#socket-identity"><code>nng_socket_raw</code></a>.</p>
<p>The <code>NNG_OPT_SENDFD</code> and <code>NNG_OPT_RECVFD</code> options have been replaced by
<a href="/api/sock.html#polling-socket-events"><code>nng_socket_get_send_poll_fd</code></a> and <a href="/api/sock.html#polling-socket-events"><code>nng_socket_get_recv_poll_fd</code></a> respectively.</p>
<p>The <code>NNG_OPT_SOCKNAME</code> function is removed. This was provided for application use, and never used internally by NNG.
Applications should keep track of this information separately.</p>
<h2 id="subscriptions"><a class="header" href="#subscriptions">Subscriptions</a></h2>
<p>The <code>NNG_OPT_SUB_SUBSCRIBE</code> and <code>NNG_OPT_SUB_UNSUBCRIBE</code> options have been replaced by
the following functions: <a href="/TODO.html"><code>nng_sub0_socket_subscribe</code></a>, <a href="/TODO.html"><code>nng_sub0_socket_unsubscribe</code></a>,
<a href="/TODO.html"><code>nng_sub0_ctx_subscribe</code></a> and <a href="/TODO.html"><code>nng_sub0_ctx_unsubscribe</code></a>. These functions, like the options
they replace, are only applicable to SUB sockets.</p>
<h2 id="statistics-use-constified-pointers"><a class="header" href="#statistics-use-constified-pointers">Statistics Use Constified Pointers</a></h2>
<p>A number of the <a href="/api/stats.html">statistics</a> functions take, or return, <code>const nng_stat *</code> instead
of plain <code>nng_stat *</code>. The ABI has not changed, but it may be necessary to declare
certain methods variables <code>const</code> to avoid warnings about misuse of <code>const</code>.</p>
<h2 id="wildcards-not-valid-in-urls"><a class="header" href="#wildcards-not-valid-in-urls">Wildcards Not Valid in URLs</a></h2>
<p>The use of <code>*</code> to act as a wild card meaning all local interface addresses
is removed. The empty string already performs this function, and unlike
<code>*</code> is RFC compliant.</p>
<h2 id="url-option-removed"><a class="header" href="#url-option-removed">URL Option Removed</a></h2>
<p>The <code>NNG_OPT_URL</code> option has been removed.
It is replaced by the type safe <a href="/TODO.html"><code>nng_dialer_get_url</code></a> and
<a href="/TODO.html"><code>nng_listener_get_url</code></a> functions, which return an <a href="/api/url.html#url-structure"><code>nng_url</code></a>
structure instead of a string.</p>
<h2 id="url-structure-changes"><a class="header" href="#url-structure-changes">URL Structure Changes</a></h2>
<p>The details of <a href="/api/url.html#url-structure"><code>nng_url</code></a> have changed significantly, and direct
access of the structure is no longer permitted. Intead new
accessors functions are provided:</p>
<ul>
<li><code>u_scheme</code> is replaced by <a href="/api/url.html#url-fields"><code>nng_url_scheme</code></a>.</li>
<li><code>u_port</code> is replaced by <a href="/api/url.html#url-fields"><code>nng_url_port</code></a>, but this returns a <code>uint16_t</code>.</li>
<li><code>u_hostname</code> is replaced by <a href="/api/url.html#url-fields"><code>nng_url_hostname</code></a>.</li>
<li><code>u_path</code> is replaced by <a href="/api/url.html#url-fields"><code>nng_url_path</code></a>.</li>
<li><code>u_query</code> is replaced by <a href="/api/url.html#url-fields"><code>nng_url_query</code></a>.</li>
<li><code>u_fragment</code> is replaced by <a href="/api/url.html#url-fields"><code>nng_url_fragment</code></a>.</li>
<li><code>u_userinfo</code> is replaced by <a href="/api/url.html#url-fields"><code>nng_url_userinfo</code></a>.</li>
<li><code>u_requri</code> is removed - it can be easily formulated from the other fields.</li>
<li><code>u_host</code> is removed - use <a href="/api/url.html#url-fields"><code>nng_url_hostname</code></a> and <a href="/api/url.html#url-fields"><code>nng_url_port</code></a> to construct if needed</li>
<li><code>u_rawurl</code> is removed - a “cooked” URL can be obtained from the new <a href="/api/url.html#format-a-url"><code>nng_url_sprintf</code></a> function.</li>
</ul>
<h2 id="http-api"><a class="header" href="#http-api">HTTP API</a></h2>
<p>A few limits on string lengths of certain values are now applied, which allows us to preallocate values
and eliminate certain unreasonable error paths. If values longer than these are supplied in certain APIs
they may be silently truncated to the limit:</p>
<ul>
<li>Hostnames are limited per RFC 1035 to 253 characters (not including terminating “.” or zero byte.)</li>
<li>HTTP Method names are limited to 32 bytes (the longest IANA registered method is currently 18 bytes, used for WebDAV.)</li>
<li>The fixed part of URI pathnames used with HTTP handlers is limited to 1024 bytes. (Longer URIs may be accepted
by using [<code>nng_http_handler_set_tree</code>] and matching a parent of the directory component.)</li>
</ul>
<p>The following API calls have changed so that they are <code>void</code> returns, and cannot fail.
They may silently truncate data.</p>
<ul>
<li>[<code>nng_http_req_set_method</code>]</li>
<li>[<code>nng_http_res_set_status</code>]</li>
<li>[<code>nng_http_handler_collect_body</code>]</li>
<li>[<code>nng_http_handler_set_data</code>]</li>
<li>[<code>nng_http_handler_set_host</code>]</li>
<li>[<code>nng_http_handler_set_method</code>]</li>
<li>[<code>nng_http_handler_set_tree</code>]</li>
<li>[<code>nng_http_handler_set_tree_exclusive</code>]</li>
</ul>
<p>The HTTP handler objects may not be modified once in use. Previously this would fail with <code>NNG_EBUSY</code>.
These checks are removed now, but debug builds will assert if an application tries to do so.</p>
<h2 id="security-descriptors-windows-only"><a class="header" href="#security-descriptors-windows-only">Security Descriptors (Windows Only)</a></h2>
<p>The <code>NNG_OPT_IPC_SECURITY_DESCRIPTOR</code> option is removed, and replaced
with the functions [<code>nng_listener_get_security_descriptor</code>] and
[<code>nng_stream_listener_get_security_descriptor</code>].</p>
<p>Security descriptor support is only relevant to Windows,
and is presently only supported for IPC when Named Pipes are used.
Planned future changes to switch to UNIX domain sockets may eliminate
support for security descriptors altogether in NNG.</p>
<h2 id="zerotier-support-removed"><a class="header" href="#zerotier-support-removed">ZeroTier Support Removed</a></h2>
<p>The Layer 2 special ZeroTier transport has been removed.
It is possible to use NNG with ZeroTier using TCP/IP, and a future update
is planned to provided coexistence between ZeroTier & the native stack’s TCP/IP using lwIP.</p>
<!-- Symbol cross reference -->
<!-- Macros -->
<!-- Protocols -->
<!-- Transports -->
<!-- Concept index -->
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../migrate/index.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../migrate/nanomsg.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="../migrate/index.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../migrate/nanomsg.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script>
window.playground_copyable = true;
</script>
<script src="../elasticlunr.min.js"></script>
<script src="../mark.min.js"></script>
<script src="../searcher.js"></script>
<script src="../clipboard.min.js"></script>
<script src="../highlight.js"></script>
<script src="../book.js"></script>
<!-- Custom JS scripts -->
<script src="../theme/pagetoc.js"></script>
</div>
</body>
</html>
|