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
|
---
version: tip
layout: manpage_v2
title: nng_tcp(7)
---
<h1>nng_tcp(7)</h1>
<div class="sect1">
<h2 id="_name">NAME</h2>
<div class="sectionbody">
<div class="paragraph">
<p>nng_tcp - TCP/IP transport</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_synopsis">SYNOPSIS</h2>
<div class="sectionbody">
<div class="listingblock">
<div class="content">
<pre class="pygments highlight"><code data-lang="c"><span></span><span class="tok-cp">#include</span><span class="tok-w"> </span><span class="tok-cpf"><nng/transport/tcp/tcp.h></span>
<span class="tok-kt">int</span><span class="tok-w"> </span><span class="tok-nf">nng_tcp_register</span><span class="tok-p">(</span><span class="tok-kt">void</span><span class="tok-p">);</span></code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_description">DESCRIPTION</h2>
<div class="sectionbody">
<div class="paragraph">
<p>
The <em>tcp</em> transport provides communication support between
sockets across a TCP/IP network.
Both IPv4 and IPv6 are supported when the underlying platform also supports it.</p>
</div>
<div class="sect2">
<h3 id="_registration">Registration</h3>
<div class="paragraph">
<p>This transport is generally built-in to the core of <em>NNG</em>, so
no extra steps to use it should be necessary.</p>
</div>
</div>
<div class="sect2">
<h3 id="_uri_format">URI Format</h3>
<div class="paragraph">
<p>
This transport uses URIs using the scheme <code>tcp://</code>, followed by
an IP address or hostname, followed by a colon and finally a
TCP port number.
For example, to contact port 80 on the localhost either of the following URIs
could be used: <code>tcp://127.0.0.1:80</code> or <code>tcp://localhost:80</code>.</p>
</div>
<div class="paragraph">
<p>A URI may be restricted to IPv6 using the scheme <code>tcp6://</code>, and may
be restricted to IPv4 using the scheme <code>tcp4://</code>.</p>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Specifying <code>tcp6://</code> may not prevent IPv4 hosts from being used with
IPv4-in-IPv6 addresses, particularly when using a wildcard hostname with
listeners.
The details of this varies across operating systems.
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
Both <code>tcp6://</code> and <code>tcp4://</code> are specific to <em>NNG</em>, and might not
be understood by other implementations.
</td>
</tr>
</table>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
We recommend using either numeric IP addresses, or names that are
specific to either IPv4 or IPv6 to prevent confusion and surprises.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>When specifying IPv6 addresses, the address must be enclosed in
square brackets (<code>[]</code>) to avoid confusion with the final colon
separating the port.</p>
</div>
<div class="paragraph">
<p>For example, the same port 80 on the IPv6 loopback address (<code>::1</code>) would
be specified as <code>tcp://[::1]:80</code>.</p>
</div>
<div class="paragraph">
<p>The special value of 0 (<code>INADDR_ANY</code>)
can be used for a listener to indicate that it should listen on all
interfaces on the host.
A short-hand for this form is to either omit the address, or specify
the asterisk (<code>*</code>) character.
For example, the following three URIs are all equivalent,
and could be used to listen to port 9999 on the host:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p><code>tcp://0.0.0.0:9999</code></p>
</li>
<li>
<p><code>tcp://*:9999</code></p>
</li>
<li>
<p><code>tcp://:9999</code></p>
</li>
</ol>
</div>
<div class="paragraph">
<p>The entire URI must be less than <code>NNG_MAXADDRLEN</code> bytes long.</p>
</div>
</div>
<div class="sect2">
<h3 id="_socket_address">Socket Address</h3>
<div class="paragraph">
<p>When using an <a href="nng_sockaddr.5.html"><code>nng_sockaddr</code></a> structure,
the actual structure is either of type
<a href="nng_sockaddr_in.5.html"><code>nng_sockaddr_in</code></a> (for IPv4) or
<a href="nng_sockaddr_in6.5.html"><code>nng_sockaddr_in6</code></a> (for IPv6).</p>
</div>
</div>
<div class="sect2">
<h3 id="_transport_options">Transport Options</h3>
<div class="paragraph">
<p>The following transport options are supported by this transport,
where supported by the underlying platform.</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="nng_options.5.html#NNG_OPT_LOCADDR"><code>NNG_OPT_LOCADDR</code></a></p>
</li>
<li>
<p><a href="nng_options.5.html#NNG_OPT_REMADDR"><code>NNG_OPT_REMADDR</code></a></p>
</li>
<li>
<p><a href="nng_tcp_options.5.html#NNG_OPT_TCP_KEEPALIVE"><code>NNG_OPT_TCP_KEEPALIVE</code></a></p>
</li>
<li>
<p><a href="nng_tcp_options.5.html#NNG_OPT_TCP_NODELAY"><code>NNG_OPT_TCP_NODELAY</code></a></p>
</li>
<li>
<p><a href="nng_options.5.html#NNG_OPT_URL"><code>NNG_OPT_URL</code></a></p>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_see_also">SEE ALSO</h2>
<div class="sectionbody">
<div class="paragraph text-left">
<p><a href="nng_options.5.html">nng_options(5)</a>,
<a href="nng_sockaddr.5.html">nng_sockaddr(5)</a>,
<a href="nng_sockaddr_in.5.html">nng_sockaddr_in(5)</a>,
<a href="nng_sockaddr_in6.5.html">nng_sockaddr_in6(5)</a>,
<a href="nng_tcp_options.5.html">nng_tcp_options(5)</a>,
<a href="nng.7.html">nng(7)</a></p>
</div>
</div>
</div>
|