Debian Codegraph @

doc/src/manual/ranch_tcp.asciidoc

raw
1 = ranch_tcp(3)
2
3 == Name
4
5 ranch_tcp - TCP transport
6
7 == Description
8
9 The module `ranch_tcp` implements a TCP Ranch transport.
10
11 The function `sendfile` may not work correctly when used
12 against files stored in a VirtualBox shared folder.
13
14 == Exports
15
16 The module `ranch_tcp` implements the interface defined
17 by link:man:ranch_transport(3)[ranch_transport(3)].
18
19 == Types
20
21 === opt()
22
23 [source,erlang]
24 ----
25 opt() = {backlog, non_neg_integer()}
26 | {buffer, non_neg_integer()}
27 | {delay_send, boolean()}
28 | {dontroute, boolean()}
29 | {exit_on_close, boolean()}
30 | {fd, non_neg_integer()}
31 | {high_msgq_watermark, non_neg_integer()}
32 | {high_watermark, non_neg_integer()}
33 | inet
34 | inet6
35 | {ip, inet:ip_address() | inet:local_address()}
36 | {ipv6_v6only, boolean()}
37 | {keepalive, boolean()}
38 | {linger, {boolean(), non_neg_integer()}}
39 | {low_msgq_watermark, non_neg_integer()}
40 | {low_watermark, non_neg_integer()}
41 | {nodelay, boolean()}
42 | {port, inet:port_number()}
43 | {priority, integer()}
44 | {raw, non_neg_integer(), non_neg_integer(), binary()}
45 | {recbuf, non_neg_integer()}
46 | {send_timeout, timeout()}
47 | {send_timeout_close, boolean()}
48 | {sndbuf, non_neg_integer()}
49 | {tos, integer()}
50 ----
51
52 Listen options.
53
54 Note that additional options may be set by the protocol
55 module using `Transport:setopts/2`.
56
57 None of the options are required.
58
59 Please consult the `gen_tcp` and `inet` manuals for a more
60 thorough description of these options. This manual only aims
61 to provide a short description along with what the defaults
62 are. Defaults may be different in Ranch compared to `gen_tcp`.
63 Defaults are given next to the option name:
64
65 backlog (1024)::
66
67 Max length of the queue of pending connections.
68
69 buffer::
70
71 Size of the buffer used by the Erlang driver. Default
72 is system-dependent.
73
74 delay_send (false)::
75
76 Always queue data before sending, to send fewer, larger
77 packets over the network.
78
79 dontroute (false)::
80
81 Don't send via a gateway, only send to directly connected hosts.
82
83 exit_on_close (true)::
84
85 Disable to allow sending data after a close has been detected.
86
87 fd::
88
89 File descriptor of the socket, if it was opened externally.
90
91 high_msgq_watermark (8192)::
92
93 Limit in the amount of data in the socket message queue before
94 the queue becomes busy.
95
96 high_watermark (8192)::
97
98 Limit in the amount of data in the ERTS socket implementation's
99 queue before the socket becomes busy.
100
101 inet::
102
103 Set up the socket for IPv4.
104
105 inet6::
106
107 Set up the socket for IPv6.
108
109 ip::
110
111 Interface to listen on. Listen on all network interfaces by default.
112
113 On UNIX systems, it is also possible to use a UNIX Domain
114 socket file by specifying `{local, SocketFile}`.
115
116 ipv6_v6only (false)::
117
118 Listen on IPv4 and IPv6 (false) or only on IPv6 (true).
119 Use with inet6.
120
121 keepalive (false)::
122
123 Enable sending of keep-alive messages.
124
125 linger ({false, 0})::
126
127 Whether to wait and how long to flush data sent before closing
128 the socket.
129
130 low_msgq_watermark (4096)::
131
132 Amount of data in the socket message queue before the queue
133 leaves busy state.
134
135 low_watermark (4096)::
136
137 Amount of data in the ERTS socket implementation's queue
138 before the socket leaves busy state.
139
140 nodelay (true)::
141
142 Whether to enable TCP_NODELAY.
143
144 port (0)::
145
146 TCP port number to listen on. 0 means a random port will be used.
147
148 priority (0)::
149
150 Priority value for all packets to be sent on this socket.
151
152 recbuf::
153
154 Minimum size of the socket's receive buffer.
155 Default is system-dependent.
156
157 send_timeout (30000)::
158
159 How long the send call may wait for confirmation before returning.
160
161 send_timeout_close (true)::
162
163 Whether to close the socket when the confirmation wasn't received.
164
165 sndbuf::
166
167 Minimum size of the socket's send buffer.
168 Default is system-dependent.
169
170 tos::
171
172 Value for the IP_TOS IP level option. Use with caution.
173
174 In addition, the `raw` option can be used to set system-specific
175 options by specifying the protocol level, the option number and
176 the actual option value specified as a binary. This option is not
177 portable. Use with caution.
178
179 === opts()
180
181 [source,erlang]
182 ----
183 opts() :: [opt()]
184 ----
185
186 List of listen options.
187
188 == See also
189
190 link:man:ranch(7)[ranch(7)],
191 link:man:ranch_transport(3)[ranch_transport(3)],
192 link:man:ranch_ssl(3)[ranch_ssl(3)],
193 gen_tcp(3),
194 inet(3)