1inet(3) Erlang Module Definition inet(3)
2
3
4
6 inet - Access to TCP/IP protocols.
7
9 This module provides access to TCP/IP protocols.
10
11 See also ERTS User's Guide: Inet Configuration for more information
12 about how to configure an Erlang runtime system for IP communication.
13
14 The following two Kernel configuration parameters affect the behavior
15 of all sockets opened on an Erlang node:
16
17 * inet_default_connect_options can contain a list of default options
18 used for all sockets returned when doing connect.
19
20 * inet_default_listen_options can contain a list of default options
21 used when issuing a listen call.
22
23 When accept is issued, the values of the listening socket options are
24 inherited. No such application variable is therefore needed for accept.
25
26 Using the Kernel configuration parameters above, one can set default
27 options for all TCP sockets on a node, but use this with care. Options
28 such as {delay_send,true} can be specified in this way. The following
29 is an example of starting an Erlang node with all sockets using delayed
30 send:
31
32 $ erl -sname test -kernel \
33 inet_default_connect_options '[{delay_send,true}]' \
34 inet_default_listen_options '[{delay_send,true}]'
35
36 Notice that default option {active, true} cannot be changed, for inter‐
37 nal reasons.
38
39 Addresses as inputs to functions can be either a string or a tuple. For
40 example, the IP address 150.236.20.73 can be passed to gethostbyaddr/1,
41 either as string "150.236.20.73" or as tuple {150, 236, 20, 73}.
42
43 IPv4 address examples:
44
45 Address ip_address()
46 ------- ------------
47 127.0.0.1 {127,0,0,1}
48 192.168.42.2 {192,168,42,2}
49
50 IPv6 address examples:
51
52 Address ip_address()
53 ------- ------------
54 ::1 {0,0,0,0,0,0,0,1}
55 ::192.168.42.2 {0,0,0,0,0,0,(192 bsl 8) bor 168,(42 bsl 8) bor 2}
56 ::FFFF:192.168.42.2
57 {0,0,0,0,0,16#FFFF,(192 bsl 8) bor 168,(42 bsl 8) bor 2}
58 3ffe:b80:1f8d:2:204:acff:fe17:bf38
59 {16#3ffe,16#b80,16#1f8d,16#2,16#204,16#acff,16#fe17,16#bf38}
60 fe80::204:acff:fe17:bf38
61 {16#fe80,0,0,0,0,16#204,16#acff,16#fe17,16#bf38}
62
63 Function parse_address/1 can be useful:
64
65 1> inet:parse_address("192.168.42.2").
66 {ok,{192,168,42,2}}
67 2> inet:parse_address("::FFFF:192.168.42.2").
68 {ok,{0,0,0,0,0,65535,49320,10754}}
69
71 hostent() =
72 #hostent{h_name = inet:hostname(),
73 h_aliases = [inet:hostname()],
74 h_addrtype = inet | inet6,
75 h_length = integer() >= 0,
76 h_addr_list = [inet:ip_address()]}
77
78 The record is defined in the Kernel include file "inet.hrl".
79
80 Add the following directive to the module:
81
82 -include_lib("kernel/include/inet.hrl").
83
84 hostname() = atom() | string()
85
86 ip_address() = ip4_address() | ip6_address()
87
88 ip4_address() = {0..255, 0..255, 0..255, 0..255}
89
90 ip6_address() =
91 {0..65535,
92 0..65535,
93 0..65535,
94 0..65535,
95 0..65535,
96 0..65535,
97 0..65535,
98 0..65535}
99
100 port_number() = 0..65535
101
102 family_address() =
103 inet_address() | inet6_address() | local_address()
104
105 A general address format on the form {Family, Destination} where
106 Family is an atom such as local and the format of Destination
107 depends on Family, and is a complete address (for example an IP
108 address including port number).
109
110 inet_address() =
111 {inet, {ip4_address() | any | loopback, port_number()}}
112
113 Warning:
114 This address format is for now experimental and for completeness
115 to make all address families have a {Family, Destination} repre‐
116 sentation.
117
118
119 inet6_address() =
120 {inet6, {ip6_address() | any | loopback, port_number()}}
121
122 Warning:
123 This address format is for now experimental and for completeness
124 to make all address families have a {Family, Destination} repre‐
125 sentation.
126
127
128 local_address() = {local, File :: binary() | string()}
129
130 This address family only works on Unix-like systems.
131
132 File is normally a file pathname in a local filesystem. It is
133 limited in length by the operating system, traditionally to 108
134 bytes.
135
136 A binary() is passed as is to the operating system, but a
137 string() is encoded according to the system filename encoding
138 mode.
139
140 Other addresses are possible, for example Linux implements
141 "Abstract Addresses". See the documentation for Unix Domain
142 Sockets on your system, normally unix in manual section 7.
143
144 In most API functions where you can use this address family the
145 port number must be 0.
146
147 socket_address() =
148 ip_address() | any | loopback | local_address()
149
150 socket_getopt() =
151 gen_sctp:option_name() |
152 gen_tcp:option_name() |
153 gen_udp:option_name()
154
155 socket_setopt() =
156 gen_sctp:option() | gen_tcp:option() | gen_udp:option()
157
158 returned_non_ip_address() =
159 {local, binary()} | {unspec, <<>>} | {undefined, any()}
160
161 Addresses besides ip_address() ones that are returned from
162 socket API functions. See in particular local_address(). The
163 unspec family corresponds to AF_UNSPEC and can occur if the
164 other side has no socket address. The undefined family can only
165 occur in the unlikely event of an address family that the VM
166 does not recognize.
167
168 ancillary_data() =
169 [{tos, byte()} | {tclass, byte()} | {ttl, byte()}]
170
171 Ancillary data received with the data packet, read with the
172 socket option pktoptions from a TCP socket, or to set in a call
173 to gen_udp:send/4 or gen_udp:send/5.
174
175 The value(s) correspond to the currently active socket options
176 recvtos, recvtclass and recvttl, or for a single send operation
177 the option(s) to override the currently active socket option(s).
178
179 getifaddrs_ifopts() =
180 [Ifopt ::
181 {flags,
182 Flags ::
183 [up | broadcast | loopback | pointtopoint |
184 running | multicast]} |
185 {addr, Addr :: ip_address()} |
186 {netmask, Netmask :: ip_address()} |
187 {broadaddr, Broadaddr :: ip_address()} |
188 {dstaddr, Dstaddr :: ip_address()} |
189 {hwaddr, Hwaddr :: [byte()]}]
190
191 Interface address description list returned from getifaddrs/0,1
192 for a named interface, translated from the returned data of the
193 POSIX API function getaddrinfo().
194
195 Hwaddr is hardware dependent, for example, on Ethernet inter‐
196 faces it is the 6-byte Ethernet address (MAC address (EUI-48
197 address)).
198
199 The tuples {addr,Addr}, {netmask,Netmask}, and possibly {broad‐
200 addr,Broadaddr} or {dstaddr,Dstaddr} are repeated in the list if
201 the interface has got multiple addresses. An interface may have
202 multiple {flag,_} tuples for example if it has different flags
203 for different address families. Multiple {hwaddr,Hwaddr} tuples
204 is hard to say anything definite about, though. The tuple
205 {flag,Flags} is mandatory, all others are optional.
206
207 Do not rely too much on the order of Flags atoms or the Ifopt
208 tuples. There are however some rules:
209
210 * A {flag,_} tuple applies to all other tuples that follow.
211
212 * Immediately after {addr,_} follows {netmask,_}.
213
214 * Immediately thereafter may {broadaddr,_} follow if broadcast
215 is member of Flags, or {dstaddr,_} if pointtopoint is member
216 of Flags. Both {dstaddr,_} and {broadaddr,_} does not occur
217 for the same {addr,_}.
218
219 * Any {netmask,_}, {broadaddr,_}, or {dstaddr,_} tuples that
220 follow an {addr,Addr} tuple concerns the address Addr.
221
222 The tuple {hwaddr,_} is not returned on Solaris, as the hardware
223 address historically belongs to the link layer and it is not
224 returned by the Solaris API function getaddrinfo().
225
226 Warning:
227 On Windows, the data is fetched from different OS API functions,
228 so the Netmask and Broadaddr values may be calculated, just as
229 some Flags values.
230
231
232 posix() =
233 eaddrinuse | eaddrnotavail | eafnosupport | ealready |
234 econnaborted | econnrefused | econnreset | edestaddrreq |
235 ehostdown | ehostunreach | einprogress | eisconn | emsgsize |
236 enetdown | enetunreach | enopkg | enoprotoopt | enotconn |
237 enotty | enotsock | eproto | eprotonosupport | eprototype |
238 esocktnosupport | etimedout | ewouldblock | exbadport |
239 exbadseq |
240 file:posix()
241
242 An atom that is named from the POSIX error codes used in Unix,
243 and in the runtime libraries of most C compilers. See section
244 POSIX Error Codes.
245
246 socket()
247
248 See gen_tcp:type-socket and gen_udp:type-socket.
249
250 address_family() = inet | inet6 | local
251
252 socket_protocol() = tcp | udp | sctp
253
254 stat_option() =
255 recv_cnt | recv_max | recv_avg | recv_oct | recv_dvi |
256 send_cnt | send_max | send_avg | send_oct | send_pend
257
259 close(Socket) -> ok
260
261 Types:
262
263 Socket = socket()
264
265 Closes a socket of any type.
266
267 format_error(Reason) -> string()
268
269 Types:
270
271 Reason = posix() | system_limit
272
273 Returns a diagnostic error string. For possible POSIX values and
274 corresponding strings, see section POSIX Error Codes.
275
276 get_rc() ->
277 [{Par :: atom(), Val :: any()} |
278 {Par :: atom(), Val1 :: any(), Val2 :: any()}]
279
280 Returns the state of the Inet configuration database in form of
281 a list of recorded configuration parameters. For more informa‐
282 tion, see ERTS User's Guide: Inet Configuration.
283
284 Only actual parameters with other than default values are
285 returned, for example not directives that specify other sources
286 for configuration parameters nor directives that clear parame‐
287 ters.
288
289 getaddr(Host, Family) -> {ok, Address} | {error, posix()}
290
291 Types:
292
293 Host = ip_address() | hostname()
294 Family = address_family()
295 Address = ip_address()
296
297 Returns the IP address for Host as a tuple of integers. Host can
298 be an IP address, a single hostname, or a fully qualified host‐
299 name.
300
301 getaddrs(Host, Family) -> {ok, Addresses} | {error, posix()}
302
303 Types:
304
305 Host = ip_address() | hostname()
306 Family = address_family()
307 Addresses = [ip_address()]
308
309 Returns a list of all IP addresses for Host. Host can be an IP
310 address, a single hostname, or a fully qualified hostname.
311
312 gethostbyaddr(Address) -> {ok, Hostent} | {error, posix()}
313
314 Types:
315
316 Address = string() | ip_address()
317 Hostent = hostent()
318
319 Returns a hostent record for the host with the specified
320 address.
321
322 gethostbyname(Hostname) -> {ok, Hostent} | {error, posix()}
323
324 Types:
325
326 Hostname = hostname()
327 Hostent = hostent()
328
329 Returns a hostent record for the host with the specified host‐
330 name.
331
332 If resolver option inet6 is true, an IPv6 address is looked up.
333
334 gethostbyname(Hostname, Family) ->
335 {ok, Hostent} | {error, posix()}
336
337 Types:
338
339 Hostname = hostname()
340 Family = address_family()
341 Hostent = hostent()
342
343 Returns a hostent record for the host with the specified name,
344 restricted to the specified address family.
345
346 gethostname() -> {ok, Hostname}
347
348 Types:
349
350 Hostname = string()
351
352 Returns the local hostname. Never fails.
353
354 getifaddrs() ->
355 {ok,
356 [{Ifname :: string(),
357 Ifopts :: getifaddrs_ifopts()}]} |
358 {error, posix()}
359
360 Returns a list of 2-tuples containing interface names and the
361 interfaces' addresses. Ifname is a Unicode string and Ifopts is
362 a list of interface address description tuples.
363
364 The interface address description tuples are documented under
365 the type of the Ifopts value.
366
367 getifaddrs(Opts) -> {ok, [{Ifname, Ifopts}]} | {error, Posix}
368
369 Types:
370
371 Opts = [{netns, Namespace}]
372 Namespace = file:filename_all()
373 Ifname = string()
374 Ifopts = getifaddrs_ifopts()
375 Posix = posix()
376
377 The same as getifaddrs/0 but the Option {netns, Namespace} sets
378 a network namespace for the OS call, on platforms that supports
379 that feature.
380
381 See the socket option {netns, Namespace} under setopts/2.
382
383 getopts(Socket, Options) -> {ok, OptionValues} | {error, posix()}
384
385 Types:
386
387 Socket = socket()
388 Options = [socket_getopt()]
389 OptionValues = [socket_setopt() | gen_tcp:pktoptions_value()]
390
391 Gets one or more options for a socket. For a list of available
392 options, see setopts/2. See also the description for the type
393 gen_tcp:pktoptions_value().
394
395 The number of elements in the returned OptionValues list does
396 not necessarily correspond to the number of options asked for.
397 If the operating system fails to support an option, it is left
398 out in the returned list. An error tuple is returned only when
399 getting options for the socket is impossible (that is, the
400 socket is closed or the buffer size in a raw request is too
401 large). This behavior is kept for backward compatibility rea‐
402 sons.
403
404 A raw option request RawOptReq = {raw, Protocol, OptionNum, Val‐
405 ueSpec} can be used to get information about socket options not
406 (explicitly) supported by the emulator. The use of raw socket
407 options makes the code non-portable, but allows the Erlang pro‐
408 grammer to take advantage of unusual features present on a par‐
409 ticular platform.
410
411 RawOptReq consists of tag raw followed by the protocol level,
412 the option number, and either a binary or the size, in bytes, of
413 the buffer in which the option value is to be stored. A binary
414 is to be used when the underlying getsockopt requires input in
415 the argument field. In this case, the binary size is to corre‐
416 spond to the required buffer size of the return value. The sup‐
417 plied values in a RawOptReq correspond to the second, third, and
418 fourth/fifth parameters to the getsockopt call in the C socket
419 API. The value stored in the buffer is returned as a binary Val‐
420 ueBin, where all values are coded in the native endianess.
421
422 Asking for and inspecting raw socket options require low-level
423 information about the current operating system and TCP stack.
424
425 Example:
426
427 Consider a Linux machine where option TCP_INFO can be used to
428 collect TCP statistics for a socket. Assume you are interested
429 in field tcpi_sacked of struct tcp_info filled in when asking
430 for TCP_INFO. To be able to access this information, you need to
431 know the following:
432
433 * The numeric value of protocol level IPPROTO_TCP
434
435 * The numeric value of option TCP_INFO
436
437 * The size of struct tcp_info
438
439 * The size and offset of the specific field
440
441 By inspecting the headers or writing a small C program, it is
442 found that IPPROTO_TCP is 6, TCP_INFO is 11, the structure size
443 is 92 (bytes), the offset of tcpi_sacked is 28 bytes, and the
444 value is a 32-bit integer. The following code can be used to
445 retrieve the value:
446
447 get_tcpi_sacked(Sock) ->
448 {ok,[{raw,_,_,Info}]} = inet:getopts(Sock,[{raw,6,11,92}]),
449 <<_:28/binary,TcpiSacked:32/native,_/binary>> = Info,
450 TcpiSacked.
451
452 Preferably, you would check the machine type, the operating sys‐
453 tem, and the Kernel version before executing anything similar to
454 this code.
455
456 getstat(Socket) -> {ok, OptionValues} | {error, posix()}
457
458 getstat(Socket, Options) -> {ok, OptionValues} | {error, posix()}
459
460 Types:
461
462 Socket = socket()
463 Options = [stat_option()]
464 OptionValues = [{stat_option(), integer()}]
465 stat_option() =
466 recv_cnt | recv_max | recv_avg | recv_oct | recv_dvi |
467 send_cnt | send_max | send_avg | send_oct | send_pend
468
469 Gets one or more statistic options for a socket.
470
471 getstat(Socket) is equivalent to getstat(Socket, [recv_avg,
472 recv_cnt, recv_dvi, recv_max, recv_oct, send_avg, send_cnt,
473 send_pend, send_max, send_oct]).
474
475 The following options are available:
476
477 recv_avg:
478 Average size of packets, in bytes, received by the socket.
479
480 recv_cnt:
481 Number of packets received by the socket.
482
483 recv_dvi:
484 Average packet size deviation, in bytes, received by the
485 socket.
486
487 recv_max:
488 Size of the largest packet, in bytes, received by the
489 socket.
490
491 recv_oct:
492 Number of bytes received by the socket.
493
494 send_avg:
495 Average size of packets, in bytes, sent from the socket.
496
497 send_cnt:
498 Number of packets sent from the socket.
499
500 send_pend:
501 Number of bytes waiting to be sent by the socket.
502
503 send_max:
504 Size of the largest packet, in bytes, sent from the socket.
505
506 send_oct:
507 Number of bytes sent from the socket.
508
509 i() -> ok
510
511 i(Proto :: socket_protocol()) -> ok
512
513 i(X1 :: socket_protocol(), Fs :: [atom()]) -> ok
514
515 Lists all TCP, UDP and SCTP sockets, including those that the
516 Erlang runtime system uses as well as those created by the
517 application.
518
519 The following options are available:
520
521 port:
522 The internal index of the port.
523
524 module:
525 The callback module of the socket.
526
527 recv:
528 Number of bytes received by the socket.
529
530 sent:
531 Number of bytes sent from the socket.
532
533 owner:
534 The socket owner process.
535
536 local_address:
537 The local address of the socket.
538
539 foreign_address:
540 The address and port of the other end of the connection.
541
542 state:
543 The connection state.
544
545 type:
546 STREAM or DGRAM or SEQPACKET.
547
548 ntoa(IpAddress) -> Address | {error, einval}
549
550 Types:
551
552 Address = string()
553 IpAddress = ip_address()
554
555 Parses an ip_address() and returns an IPv4 or IPv6 address
556 string.
557
558 parse_address(Address) -> {ok, IPAddress} | {error, einval}
559
560 Types:
561
562 Address = string()
563 IPAddress = ip_address()
564
565 Parses an IPv4 or IPv6 address string and returns an
566 ip4_address() or ip6_address(). Accepts a shortened IPv4 address
567 string.
568
569 parse_ipv4_address(Address) -> {ok, IPv4Address} | {error, einval}
570
571 Types:
572
573 Address = string()
574 IPv4Address = ip_address()
575
576 Parses an IPv4 address string and returns an ip4_address().
577 Accepts a shortened IPv4 address string.
578
579 parse_ipv4strict_address(Address) ->
580 {ok, IPv4Address} | {error, einval}
581
582 Types:
583
584 Address = string()
585 IPv4Address = ip_address()
586
587 Parses an IPv4 address string containing four fields, that is,
588 not shortened, and returns an ip4_address().
589
590 parse_ipv6_address(Address) -> {ok, IPv6Address} | {error, einval}
591
592 Types:
593
594 Address = string()
595 IPv6Address = ip_address()
596
597 Parses an IPv6 address string and returns an ip6_address(). If
598 an IPv4 address string is specified, an IPv4-mapped IPv6 address
599 is returned.
600
601 parse_ipv6strict_address(Address) ->
602 {ok, IPv6Address} | {error, einval}
603
604 Types:
605
606 Address = string()
607 IPv6Address = ip_address()
608
609 Parses an IPv6 address string and returns an ip6_address(). Does
610 not accept IPv4 addresses.
611
612 ipv4_mapped_ipv6_address(X1 :: ip_address()) -> ip_address()
613
614 Convert an IPv4 address to an IPv4-mapped IPv6 address or the
615 reverse. When converting from an IPv6 address all but the 2 low
616 words are ignored so this function also works on some other
617 types of addresses than IPv4-mapped.
618
619 parse_strict_address(Address) -> {ok, IPAddress} | {error, einval}
620
621 Types:
622
623 Address = string()
624 IPAddress = ip_address()
625
626 Parses an IPv4 or IPv6 address string and returns an
627 ip4_address() or ip6_address(). Does not accept a shortened IPv4
628 address string.
629
630 peername(Socket :: socket()) ->
631 {ok,
632 {ip_address(), port_number()} |
633 returned_non_ip_address()} |
634 {error, posix()}
635
636 Returns the address and port for the other end of a connection.
637
638 Notice that for SCTP sockets, this function returns only one of
639 the peer addresses of the socket. Function peernames/1,2 returns
640 all.
641
642 peernames(Socket :: socket()) ->
643 {ok,
644 [{ip_address(), port_number()} |
645 returned_non_ip_address()]} |
646 {error, posix()}
647
648 Equivalent to peernames(Socket, 0).
649
650 Notice that the behavior of this function for an SCTP one-to-
651 many style socket is not defined by the SCTP Sockets API Exten‐
652 sions.
653
654 peernames(Socket, Assoc) ->
655 {ok, [{Address, Port}]} | {error, posix()}
656
657 Types:
658
659 Socket = socket()
660 Assoc = #sctp_assoc_change{} | gen_sctp:assoc_id()
661 Address = ip_address()
662 Port = integer() >= 0
663
664 Returns a list of all address/port number pairs for the other
665 end of an association Assoc of a socket.
666
667 This function can return multiple addresses for multihomed sock‐
668 ets, such as SCTP sockets. For other sockets it returns a one-
669 element list.
670
671 Notice that parameter Assoc is by the SCTP Sockets API Exten‐
672 sions defined to be ignored for one-to-one style sockets. What
673 the special value 0 means, hence its behavior for one-to-many
674 style sockets, is unfortunately undefined.
675
676 port(Socket) -> {ok, Port} | {error, any()}
677
678 Types:
679
680 Socket = socket()
681 Port = port_number()
682
683 Returns the local port number for a socket.
684
685 setopts(Socket, Options) -> ok | {error, posix()}
686
687 Types:
688
689 Socket = socket()
690 Options = [socket_setopt()]
691
692 Sets one or more options for a socket.
693
694 The following options are available:
695
696 {active, true | false | once | N}:
697 If the value is true, which is the default, everything
698 received from the socket is sent as messages to the receiv‐
699 ing process.
700
701 If the value is false (passive mode), the process must
702 explicitly receive incoming data by calling
703 gen_tcp:recv/2,3, gen_udp:recv/2,3, or gen_sctp:recv/1,2
704 (depending on the type of socket).
705
706 If the value is once ({active, once}), one data message from
707 the socket is sent to the process. To receive one more mes‐
708 sage, setopts/2 must be called again with option {active,
709 once}.
710
711 If the value is an integer N in the range -32768 to 32767
712 (inclusive), the value is added to the socket's count of
713 data messages sent to the controlling process. A socket's
714 default message count is 0. If a negative value is speci‐
715 fied, and its magnitude is equal to or greater than the
716 socket's current message count, the socket's message count
717 is set to 0. Once the socket's message count reaches 0,
718 either because of sending received data messages to the
719 process or by being explicitly set, the process is then
720 notified by a special message, specific to the type of
721 socket, that the socket has entered passive mode. Once the
722 socket enters passive mode, to receive more messages
723 setopts/2 must be called again to set the socket back into
724 an active mode.
725
726 When using {active, once} or {active, N}, the socket changes
727 behavior automatically when data is received. This can be
728 confusing in combination with connection-oriented sockets
729 (that is, gen_tcp), as a socket with {active, false} behav‐
730 ior reports closing differently than a socket with {active,
731 true} behavior. To simplify programming, a socket where the
732 peer closed, and this is detected while in {active, false}
733 mode, still generates message {tcp_closed,Socket} when set
734 to {active, once}, {active, true}, or {active, N} mode. It
735 is therefore safe to assume that message
736 {tcp_closed,Socket}, possibly followed by socket port termi‐
737 nation (depending on option exit_on_close) eventually
738 appears when a socket changes back and forth between
739 {active, true} and {active, false} mode. However, when peer
740 closing is detected it is all up to the underlying TCP/IP
741 stack and protocol.
742
743 Notice that {active, true} mode provides no flow control; a
744 fast sender can easily overflow the receiver with incoming
745 messages. The same is true for {active, N} mode, while the
746 message count is greater than zero.
747
748 Use active mode only if your high-level protocol provides
749 its own flow control (for example, acknowledging received
750 messages) or the amount of data exchanged is small. {active,
751 false} mode, use of the {active, once} mode, or {active, N}
752 mode with values of N appropriate for the application pro‐
753 vides flow control. The other side cannot send faster than
754 the receiver can read.
755
756 {broadcast, Boolean} (UDP sockets):
757 Enables/disables permission to send broadcasts.
758
759 {buffer, Size}:
760 The size of the user-level buffer used by the driver. Not to
761 be confused with options sndbuf and recbuf, which correspond
762 to the Kernel socket buffers. For TCP it is recommended to
763 have val(buffer) >= val(recbuf) to avoid performance issues
764 because of unnecessary copying. For UDP the same recommenda‐
765 tion applies, but the max should not be larger than the MTU
766 of the network path. val(buffer) is automatically set to the
767 above maximum when recbuf is set. However, as the size set
768 for recbuf usually become larger, you are encouraged to use
769 getopts/2 to analyze the behavior of your operating system.
770
771 Note that this is also the maximum amount of data that can
772 be received from a single recv call. If you are using higher
773 than normal MTU consider setting buffer higher.
774
775 {delay_send, Boolean}:
776 Normally, when an Erlang process sends to a socket, the
777 driver tries to send the data immediately. If that fails,
778 the driver uses any means available to queue up the message
779 to be sent whenever the operating system says it can handle
780 it. Setting {delay_send, true} makes all messages queue up.
781 The messages sent to the network are then larger but fewer.
782 The option affects the scheduling of send requests versus
783 Erlang processes instead of changing any real property of
784 the socket. The option is implementation-specific. Defaults
785 to false.
786
787 {deliver, port | term}:
788 When {active, true}, data is delivered on the form port :
789 {S, {data, [H1,..Hsz | Data]}} or term : {tcp, S, [H1..Hsz |
790 Data]}.
791
792 {dontroute, Boolean}:
793 Enables/disables routing bypass for outgoing messages.
794
795 {exit_on_close, Boolean}:
796 This option is set to true by default.
797
798 The only reason to set it to false is if you want to con‐
799 tinue sending data to the socket after a close is detected,
800 for example, if the peer uses gen_tcp:shutdown/2 to shut
801 down the write side.
802
803 {header, Size}:
804 This option is only meaningful if option binary was speci‐
805 fied when the socket was created. If option header is speci‐
806 fied, the first Size number bytes of data received from the
807 socket are elements of a list, and the remaining data is a
808 binary specified as the tail of the same list. For example,
809 if Size == 2, the data received matches
810 [Byte1,Byte2|Binary].
811
812 {high_msgq_watermark, Size}:
813 The socket message queue is set to a busy state when the
814 amount of data on the message queue reaches this limit.
815 Notice that this limit only concerns data that has not yet
816 reached the ERTS internal socket implementation. Defaults to
817 8 kB.
818
819 Senders of data to the socket are suspended if either the
820 socket message queue is busy or the socket itself is busy.
821
822 For more information, see options low_msgq_watermark,
823 high_watermark, and low_watermark.
824
825 Notice that distribution sockets disable the use of
826 high_msgq_watermark and low_msgq_watermark. Instead use the
827 distribution buffer busy limit, which is a similar feature.
828
829 {high_watermark, Size} (TCP/IP sockets):
830 The socket is set to a busy state when the amount of data
831 queued internally by the ERTS socket implementation reaches
832 this limit. Defaults to 8 kB.
833
834 Senders of data to the socket are suspended if either the
835 socket message queue is busy or the socket itself is busy.
836
837 For more information, see options low_watermark,
838 high_msgq_watermark, and low_msqg_watermark.
839
840 {ipv6_v6only, Boolean}:
841 Restricts the socket to use only IPv6, prohibiting any IPv4
842 connections. This is only applicable for IPv6 sockets
843 (option inet6).
844
845 On most platforms this option must be set on the socket
846 before associating it to an address. It is therefore only
847 reasonable to specify it when creating the socket and not to
848 use it when calling function (setopts/2) containing this
849 description.
850
851 The behavior of a socket with this option set to true is the
852 only portable one. The original idea when IPv6 was new of
853 using IPv6 for all traffic is now not recommended by FreeBSD
854 (you can use {ipv6_v6only,false} to override the recommended
855 system default value), forbidden by OpenBSD (the supported
856 GENERIC kernel), and impossible on Windows (which has sepa‐
857 rate IPv4 and IPv6 protocol stacks). Most Linux distros
858 still have a system default value of false. This policy
859 shift among operating systems to separate IPv6 from IPv4
860 traffic has evolved, as it gradually proved hard and compli‐
861 cated to get a dual stack implementation correct and secure.
862
863 On some platforms, the only allowed value for this option is
864 true, for example, OpenBSD and Windows. Trying to set this
865 option to false, when creating the socket, fails in this
866 case.
867
868 Setting this option on platforms where it does not exist is
869 ignored. Getting this option with getopts/2 returns no
870 value, that is, the returned list does not contain an
871 {ipv6_v6only,_} tuple. On Windows, the option does not
872 exist, but it is emulated as a read-only option with value
873 true.
874
875 Therefore, setting this option to true when creating a
876 socket never fails, except possibly on a platform where you
877 have customized the kernel to only allow false, which can be
878 doable (but awkward) on, for example, OpenBSD.
879
880 If you read back the option value using getopts/2 and get no
881 value, the option does not exist in the host operating sys‐
882 tem. The behavior of both an IPv6 and an IPv4 socket listen‐
883 ing on the same port, and for an IPv6 socket getting IPv4
884 traffic is then no longer predictable.
885
886 {keepalive, Boolean}(TCP/IP sockets):
887 Enables/disables periodic transmission on a connected socket
888 when no other data is exchanged. If the other end does not
889 respond, the connection is considered broken and an error
890 message is sent to the controlling process. Defaults to dis‐
891 abled.
892
893 {linger, {true|false, Seconds}}:
894 Determines the time-out, in seconds, for flushing unsent
895 data in the close/1 socket call.
896
897 The first component is if linger is enabled, the second com‐
898 ponent is the flushing time-out, in seconds. There are 3
899 alternatives:
900
901 {false, _}:
902 close/1 or shutdown/2 returns immediately, not waiting for
903 data to be flushed, with closing happening in the back‐
904 ground.
905
906 {true, 0}:
907 Aborts the connection when it is closed. Discards any data
908 still remaining in the send buffers and sends RST to the
909 peer.
910
911 This avoids TCP's TIME_WAIT state, but leaves open the
912 possibility that another "incarnation" of this connection
913 being created.
914
915 {true, Time} when Time > 0:
916 close/1 or shutdown/2 will not return until all queued
917 messages for the socket have been successfully sent or the
918 linger timeout (Time) has been reached.
919
920 {low_msgq_watermark, Size}:
921 If the socket message queue is in a busy state, the socket
922 message queue is set in a not busy state when the amount of
923 data queued in the message queue falls below this limit.
924 Notice that this limit only concerns data that has not yet
925 reached the ERTS internal socket implementation. Defaults to
926 4 kB.
927
928 Senders that are suspended because of either a busy message
929 queue or a busy socket are resumed when the socket message
930 queue and the socket are not busy.
931
932 For more information, see options high_msgq_watermark,
933 high_watermark, and low_watermark.
934
935 Notice that distribution sockets disable the use of
936 high_msgq_watermark and low_msgq_watermark. Instead they use
937 the distribution buffer busy limit, which is a similar fea‐
938 ture.
939
940 {low_watermark, Size} (TCP/IP sockets):
941 If the socket is in a busy state, the socket is set in a not
942 busy state when the amount of data queued internally by the
943 ERTS socket implementation falls below this limit. Defaults
944 to 4 kB.
945
946 Senders that are suspended because of a busy message queue
947 or a busy socket are resumed when the socket message queue
948 and the socket are not busy.
949
950 For more information, see options high_watermark,
951 high_msgq_watermark, and low_msgq_watermark.
952
953 {mode, Mode :: binary | list}:
954 Received Packet is delivered as defined by Mode.
955
956 {netns, Namespace :: file:filename_all()}:
957 Sets a network namespace for the socket. Parameter Namespace
958 is a filename defining the namespace, for example,
959 "/var/run/netns/example", typically created by command ip
960 netns add example. This option must be used in a function
961 call that creates a socket, that is, gen_tcp:connect/3,4,
962 gen_tcp:listen/2, gen_udp:open/1,2 or gen_sctp:open/0,1,2,
963 and also getifaddrs/1.
964
965 This option uses the Linux-specific syscall setns(), such as
966 in Linux kernel 3.0 or later, and therefore only exists when
967 the runtime system is compiled for such an operating system.
968
969 The virtual machine also needs elevated privileges, either
970 running as superuser or (for Linux) having capability
971 CAP_SYS_ADMIN according to the documentation for setns(2).
972 However, during testing also CAP_SYS_PTRACE and
973 CAP_DAC_READ_SEARCH have proven to be necessary.
974
975 Example:
976
977 setcap cap_sys_admin,cap_sys_ptrace,cap_dac_read_search+epi beam.smp
978
979 Notice that the filesystem containing the virtual machine
980 executable (beam.smp in the example) must be local, mounted
981 without flag nosetuid, support extended attributes, and the
982 kernel must support file capabilities. All this runs out of
983 the box on at least Ubuntu 12.04 LTS, except that SCTP sock‐
984 ets appear to not support network namespaces.
985
986 Namespace is a filename and is encoded and decoded as dis‐
987 cussed in module file, with the following exceptions:
988
989 * Emulator flag +fnu is ignored.
990
991 * getopts/2 for this option returns a binary for the file‐
992 name if the stored filename cannot be decoded. This is
993 only to occur if you set the option using a binary that
994 cannot be decoded with the emulator's filename encoding:
995 file:native_name_encoding/0.
996
997 {bind_to_device, Ifname :: binary()}:
998 Binds a socket to a specific network interface. This option
999 must be used in a function call that creates a socket, that
1000 is, gen_tcp:connect/3,4, gen_tcp:listen/2, gen_udp:open/1,2,
1001 or gen_sctp:open/0,1,2.
1002
1003 Unlike getifaddrs/0, Ifname is encoded a binary. In the
1004 unlikely case that a system is using non-7-bit-ASCII charac‐
1005 ters in network device names, special care has to be taken
1006 when encoding this argument.
1007
1008 This option uses the Linux-specific socket option SO_BIND‐
1009 TODEVICE, such as in Linux kernel 2.0.30 or later, and
1010 therefore only exists when the runtime system is compiled
1011 for such an operating system.
1012
1013 Before Linux 3.8, this socket option could be set, but could
1014 not retrieved with getopts/2. Since Linux 3.8, it is read‐
1015 able.
1016
1017 The virtual machine also needs elevated privileges, either
1018 running as superuser or (for Linux) having capability
1019 CAP_NET_RAW.
1020
1021 The primary use case for this option is to bind sockets into
1022 Linux VRF instances.
1023
1024 list:
1025 Received Packet is delivered as a list.
1026
1027 binary:
1028 Received Packet is delivered as a binary.
1029
1030 {nodelay, Boolean}(TCP/IP sockets):
1031 If Boolean == true, option TCP_NODELAY is turned on for the
1032 socket, which means that also small amounts of data are sent
1033 immediately.
1034
1035 {nopush, Boolean}(TCP/IP sockets):
1036 This translates to TCP_NOPUSH on BSD and to TCP_CORK on
1037 Linux.
1038
1039 If Boolean == true, the corresponding option is turned on
1040 for the socket, which means that small amounts of data are
1041 accumulated until a full MSS-worth of data is available or
1042 this option is turned off.
1043
1044 Note that while TCP_NOPUSH socket option is available on
1045 OSX, its semantics is very different (e.g., unsetting it
1046 does not cause immediate send of accumulated data). Hence,
1047 nopush option is intentionally ignored on OSX.
1048
1049 {packet, PacketType}(TCP/IP sockets):
1050 Defines the type of packets to use for a socket. Possible
1051 values:
1052
1053 raw | 0:
1054 No packaging is done.
1055
1056 1 | 2 | 4:
1057 Packets consist of a header specifying the number of bytes
1058 in the packet, followed by that number of bytes. The
1059 header length can be one, two, or four bytes, and contain‐
1060 ing an unsigned integer in big-endian byte order. Each
1061 send operation generates the header, and the header is
1062 stripped off on each receive operation.
1063
1064 The 4-byte header is limited to 2Gb.
1065
1066 asn1 | cdr | sunrm | fcgi | tpkt | line:
1067 These packet types only have effect on receiving. When
1068 sending a packet, it is the responsibility of the applica‐
1069 tion to supply a correct header. On receiving, however,
1070 one message is sent to the controlling process for each
1071 complete packet received, and, similarly, each call to
1072 gen_tcp:recv/2,3 returns one complete packet. The header
1073 is not stripped off.
1074
1075 The meanings of the packet types are as follows:
1076
1077 * asn1 - ASN.1 BER
1078
1079 * sunrm - Sun's RPC encoding
1080
1081 * cdr - CORBA (GIOP 1.1)
1082
1083 * fcgi - Fast CGI
1084
1085 * tpkt - TPKT format [RFC1006]
1086
1087 * line - Line mode, a packet is a line-terminated with
1088 newline, lines longer than the receive buffer are trun‐
1089 cated
1090
1091 http | http_bin:
1092 The Hypertext Transfer Protocol. The packets are returned
1093 with the format according to HttpPacket described in
1094 erlang:decode_packet/3 in ERTS. A socket in passive mode
1095 returns {ok, HttpPacket} from gen_tcp:recv while an active
1096 socket sends messages like {http, Socket, HttpPacket}.
1097
1098 httph | httph_bin:
1099 These two types are often not needed, as the socket auto‐
1100 matically switches from http/http_bin to httph/httph_bin
1101 internally after the first line is read. However, there
1102 can be occasions when they are useful, such as parsing
1103 trailers from chunked encoding.
1104
1105 {packet_size, Integer}(TCP/IP sockets):
1106 Sets the maximum allowed length of the packet body. If the
1107 packet header indicates that the length of the packet is
1108 longer than the maximum allowed length, the packet is con‐
1109 sidered invalid. The same occurs if the packet header is too
1110 large for the socket receive buffer.
1111
1112 For line-oriented protocols (line, http*), option
1113 packet_size also guarantees that lines up to the indicated
1114 length are accepted and not considered invalid because of
1115 internal buffer limitations.
1116
1117 {line_delimiter, Char}(TCP/IP sockets):
1118 Sets the line delimiting character for line-oriented proto‐
1119 cols (line). Defaults to $\n.
1120
1121 {raw, Protocol, OptionNum, ValueBin}:
1122 See below.
1123
1124 {read_packets, Integer}(UDP sockets):
1125 Sets the maximum number of UDP packets to read without
1126 intervention from the socket when data is available. When
1127 this many packets have been read and delivered to the desti‐
1128 nation process, new packets are not read until a new notifi‐
1129 cation of available data has arrived. Defaults to 5. If this
1130 parameter is set too high, the system can become unrespon‐
1131 sive because of UDP packet flooding.
1132
1133 {recbuf, Size}:
1134 The minimum size of the receive buffer to use for the
1135 socket. You are encouraged to use getopts/2 to retrieve the
1136 size set by your operating system.
1137
1138 {recvtclass, Boolean}:
1139 If set to true activates returning the received TCLASS value
1140 on platforms that implements the protocol IPPROTO_IPV6
1141 option IPV6_RECVTCLASS or IPV6_2292RECVTCLASS for the
1142 socket. The value is returned as a {tclass,TCLASS} tuple
1143 regardless of if the platform returns an IPV6_TCLASS or an
1144 IPV6_RECVTCLASS CMSG value.
1145
1146 For packet oriented sockets that supports receiving ancil‐
1147 lary data with the payload data (gen_udp and gen_sctp), the
1148 TCLASS value is returned in an extended return tuple con‐
1149 tained in an ancillary data list. For stream oriented
1150 sockets (gen_tcp) the only way to get the TCLASS value is if
1151 the platform supports the pktoptions option.
1152
1153 {recvtos, Boolean}:
1154 If set to true activates returning the received TOS value on
1155 platforms that implements the protocol IPPROTO_IP option
1156 IP_RECVTOS for the socket. The value is returned as a
1157 {tos,TOS} tuple regardless of if the platform returns an
1158 IP_TOS or an IP_RECVTOS CMSG value.
1159
1160 For packet oriented sockets that supports receiving ancil‐
1161 lary data with the payload data (gen_udp and gen_sctp), the
1162 TOS value is returned in an extended return tuple contained
1163 in an ancillary data list. For stream oriented sockets
1164 (gen_tcp) the only way to get the TOS value is if the plat‐
1165 form supports the pktoptions option.
1166
1167 {recvttl, Boolean}:
1168 If set to true activates returning the received TTL value on
1169 platforms that implements the protocol IPPROTO_IP option
1170 IP_RECVTTL for the socket. The value is returned as a
1171 {ttl,TTL} tuple regardless of if the platform returns an
1172 IP_TTL or an IP_RECVTTL CMSG value.
1173
1174 For packet oriented sockets that supports receiving ancil‐
1175 lary data with the payload data (gen_udp and gen_sctp), the
1176 TTL value is returned in an extended return tuple contained
1177 in an ancillary data list. For stream oriented sockets
1178 (gen_tcp) the only way to get the TTL value is if the plat‐
1179 form supports the pktoptions option.
1180
1181 {reuseaddr, Boolean}:
1182 Allows or disallows local reuse of port numbers. By default,
1183 reuse is disallowed.
1184
1185 {send_timeout, Integer}:
1186 Only allowed for connection-oriented sockets.
1187
1188 Specifies a longest time to wait for a send operation to be
1189 accepted by the underlying TCP stack. When the limit is
1190 exceeded, the send operation returns {error,timeout}. How
1191 much of a packet that got sent is unknown; the socket is
1192 therefore to be closed whenever a time-out has occurred (see
1193 send_timeout_close below). Defaults to infinity.
1194
1195 {send_timeout_close, Boolean}:
1196 Only allowed for connection-oriented sockets.
1197
1198 Used together with send_timeout to specify whether the
1199 socket is to be automatically closed when the send operation
1200 returns {error,timeout}. The recommended setting is true,
1201 which automatically closes the socket. Defaults to false
1202 because of backward compatibility.
1203
1204 {show_econnreset, Boolean}(TCP/IP sockets):
1205 When this option is set to false, which is default, an RST
1206 received from the TCP peer is treated as a normal close (as
1207 though an FIN was sent). A caller to gen_tcp:recv/2 gets
1208 {error, closed}. In active mode, the controlling process
1209 receives a {tcp_closed, Socket} message, indicating that the
1210 peer has closed the connection.
1211
1212 Setting this option to true allows you to distinguish
1213 between a connection that was closed normally, and one that
1214 was aborted (intentionally or unintentionally) by the TCP
1215 peer. A call to gen_tcp:recv/2 returns {error, econnreset}.
1216 In active mode, the controlling process receives a
1217 {tcp_error, Socket, econnreset} message before the usual
1218 {tcp_closed, Socket}, as is the case for any other socket
1219 error. Calls to gen_tcp:send/2 also returns {error, econnre‐
1220 set} when it is detected that a TCP peer has sent an RST.
1221
1222 A connected socket returned from gen_tcp:accept/1 inherits
1223 the show_econnreset setting from the listening socket.
1224
1225 {sndbuf, Size}:
1226 The minimum size of the send buffer to use for the socket.
1227 You are encouraged to use getopts/2, to retrieve the size
1228 set by your operating system.
1229
1230 {priority, Integer}:
1231 Sets the SO_PRIORITY socket level option on platforms where
1232 this is implemented. The behavior and allowed range varies
1233 between different systems. The option is ignored on plat‐
1234 forms where it is not implemented. Use with caution.
1235
1236 {tos, Integer}:
1237 Sets IP_TOS IP level options on platforms where this is
1238 implemented. The behavior and allowed range varies between
1239 different systems. The option is ignored on platforms where
1240 it is not implemented. Use with caution.
1241
1242 {tclass, Integer}:
1243 Sets IPV6_TCLASS IP level options on platforms where this is
1244 implemented. The behavior and allowed range varies between
1245 different systems. The option is ignored on platforms where
1246 it is not implemented. Use with caution.
1247
1248 In addition to these options, raw option specifications can be
1249 used. The raw options are specified as a tuple of arity four,
1250 beginning with tag raw, followed by the protocol level, the
1251 option number, and the option value specified as a binary. This
1252 corresponds to the second, third, and fourth arguments to the
1253 setsockopt call in the C socket API. The option value must be
1254 coded in the native endianess of the platform and, if a struc‐
1255 ture is required, must follow the structure alignment conven‐
1256 tions on the specific platform.
1257
1258 Using raw socket options requires detailed knowledge about the
1259 current operating system and TCP stack.
1260
1261 Example:
1262
1263 This example concerns the use of raw options. Consider a Linux
1264 system where you want to set option TCP_LINGER2 on protocol
1265 level IPPROTO_TCP in the stack. You know that on this particular
1266 system it defaults to 60 (seconds), but you want to lower it to
1267 30 for a particular socket. Option TCP_LINGER2 is not explicitly
1268 supported by inet, but you know that the protocol level trans‐
1269 lates to number 6, the option number to number 8, and the value
1270 is to be specified as a 32-bit integer. You can use this code
1271 line to set the option for the socket named Sock:
1272
1273 inet:setopts(Sock,[{raw,6,8,<<30:32/native>>}]),
1274
1275 As many options are silently discarded by the stack if they are
1276 specified out of range; it can be a good idea to check that a
1277 raw option is accepted. The following code places the value in
1278 variable TcpLinger2:
1279
1280 {ok,[{raw,6,8,<<TcpLinger2:32/native>>}]}=inet:getopts(Sock,[{raw,6,8,4}]),
1281
1282 Code such as these examples is inherently non-portable, even
1283 different versions of the same OS on the same platform can
1284 respond differently to this kind of option manipulation. Use
1285 with care.
1286
1287 Notice that the default options for TCP/IP sockets can be
1288 changed with the Kernel configuration parameters mentioned in
1289 the beginning of this manual page.
1290
1291 sockname(Socket :: socket()) ->
1292 {ok,
1293 {ip_address(), port_number()} |
1294 returned_non_ip_address()} |
1295 {error, posix()}
1296
1297 Returns the local address and port number for a socket.
1298
1299 Notice that for SCTP sockets this function returns only one of
1300 the socket addresses. Function socknames/1,2 returns all.
1301
1302 socknames(Socket :: socket()) ->
1303 {ok,
1304 [{ip_address(), port_number()} |
1305 returned_non_ip_address()]} |
1306 {error, posix()}
1307
1308 Equivalent to socknames(Socket, 0).
1309
1310 socknames(Socket, Assoc) ->
1311 {ok, [{Address, Port}]} | {error, posix()}
1312
1313 Types:
1314
1315 Socket = socket()
1316 Assoc = #sctp_assoc_change{} | gen_sctp:assoc_id()
1317 Address = ip_address()
1318 Port = integer() >= 0
1319
1320 Returns a list of all local address/port number pairs for a
1321 socket for the specified association Assoc.
1322
1323 This function can return multiple addresses for multihomed sock‐
1324 ets, such as SCTP sockets. For other sockets it returns a one-
1325 element list.
1326
1327 Notice that parameter Assoc is by the SCTP Sockets API Exten‐
1328 sions defined to be ignored for one-to-one style sockets. For
1329 one-to-many style sockets, the special value 0 is defined to
1330 mean that the returned addresses must be without any particular
1331 association. How different SCTP implementations interpret this
1332 varies somewhat.
1333
1335 * e2big - Too long argument list
1336
1337 * eacces - Permission denied
1338
1339 * eaddrinuse - Address already in use
1340
1341 * eaddrnotavail - Cannot assign requested address
1342
1343 * eadv - Advertise error
1344
1345 * eafnosupport - Address family not supported by protocol family
1346
1347 * eagain - Resource temporarily unavailable
1348
1349 * ealign - EALIGN
1350
1351 * ealready - Operation already in progress
1352
1353 * ebade - Bad exchange descriptor
1354
1355 * ebadf - Bad file number
1356
1357 * ebadfd - File descriptor in bad state
1358
1359 * ebadmsg - Not a data message
1360
1361 * ebadr - Bad request descriptor
1362
1363 * ebadrpc - Bad RPC structure
1364
1365 * ebadrqc - Bad request code
1366
1367 * ebadslt - Invalid slot
1368
1369 * ebfont - Bad font file format
1370
1371 * ebusy - File busy
1372
1373 * echild - No children
1374
1375 * echrng - Channel number out of range
1376
1377 * ecomm - Communication error on send
1378
1379 * econnaborted - Software caused connection abort
1380
1381 * econnrefused - Connection refused
1382
1383 * econnreset - Connection reset by peer
1384
1385 * edeadlk - Resource deadlock avoided
1386
1387 * edeadlock - Resource deadlock avoided
1388
1389 * edestaddrreq - Destination address required
1390
1391 * edirty - Mounting a dirty fs without force
1392
1393 * edom - Math argument out of range
1394
1395 * edotdot - Cross mount point
1396
1397 * edquot - Disk quota exceeded
1398
1399 * eduppkg - Duplicate package name
1400
1401 * eexist - File already exists
1402
1403 * efault - Bad address in system call argument
1404
1405 * efbig - File too large
1406
1407 * ehostdown - Host is down
1408
1409 * ehostunreach - Host is unreachable
1410
1411 * eidrm - Identifier removed
1412
1413 * einit - Initialization error
1414
1415 * einprogress - Operation now in progress
1416
1417 * eintr - Interrupted system call
1418
1419 * einval - Invalid argument
1420
1421 * eio - I/O error
1422
1423 * eisconn - Socket is already connected
1424
1425 * eisdir - Illegal operation on a directory
1426
1427 * eisnam - Is a named file
1428
1429 * el2hlt - Level 2 halted
1430
1431 * el2nsync - Level 2 not synchronized
1432
1433 * el3hlt - Level 3 halted
1434
1435 * el3rst - Level 3 reset
1436
1437 * elbin - ELBIN
1438
1439 * elibacc - Cannot access a needed shared library
1440
1441 * elibbad - Accessing a corrupted shared library
1442
1443 * elibexec - Cannot exec a shared library directly
1444
1445 * elibmax - Attempting to link in more shared libraries than system
1446 limit
1447
1448 * elibscn - .lib section in a.out corrupted
1449
1450 * elnrng - Link number out of range
1451
1452 * eloop - Too many levels of symbolic links
1453
1454 * emfile - Too many open files
1455
1456 * emlink - Too many links
1457
1458 * emsgsize - Message too long
1459
1460 * emultihop - Multihop attempted
1461
1462 * enametoolong - Filename too long
1463
1464 * enavail - Unavailable
1465
1466 * enet - ENET
1467
1468 * enetdown - Network is down
1469
1470 * enetreset - Network dropped connection on reset
1471
1472 * enetunreach - Network is unreachable
1473
1474 * enfile - File table overflow
1475
1476 * enoano - Anode table overflow
1477
1478 * enobufs - No buffer space available
1479
1480 * enocsi - No CSI structure available
1481
1482 * enodata - No data available
1483
1484 * enodev - No such device
1485
1486 * enoent - No such file or directory
1487
1488 * enoexec - Exec format error
1489
1490 * enolck - No locks available
1491
1492 * enolink - Link has been severed
1493
1494 * enomem - Not enough memory
1495
1496 * enomsg - No message of desired type
1497
1498 * enonet - Machine is not on the network
1499
1500 * enopkg - Package not installed
1501
1502 * enoprotoopt - Bad protocol option
1503
1504 * enospc - No space left on device
1505
1506 * enosr - Out of stream resources or not a stream device
1507
1508 * enosym - Unresolved symbol name
1509
1510 * enosys - Function not implemented
1511
1512 * enotblk - Block device required
1513
1514 * enotconn - Socket is not connected
1515
1516 * enotdir - Not a directory
1517
1518 * enotempty - Directory not empty
1519
1520 * enotnam - Not a named file
1521
1522 * enotsock - Socket operation on non-socket
1523
1524 * enotsup - Operation not supported
1525
1526 * enotty - Inappropriate device for ioctl
1527
1528 * enotuniq - Name not unique on network
1529
1530 * enxio - No such device or address
1531
1532 * eopnotsupp - Operation not supported on socket
1533
1534 * eperm - Not owner
1535
1536 * epfnosupport - Protocol family not supported
1537
1538 * epipe - Broken pipe
1539
1540 * eproclim - Too many processes
1541
1542 * eprocunavail - Bad procedure for program
1543
1544 * eprogmismatch - Wrong program version
1545
1546 * eprogunavail - RPC program unavailable
1547
1548 * eproto - Protocol error
1549
1550 * eprotonosupport - Protocol not supported
1551
1552 * eprototype - Wrong protocol type for socket
1553
1554 * erange - Math result unrepresentable
1555
1556 * erefused - EREFUSED
1557
1558 * eremchg - Remote address changed
1559
1560 * eremdev - Remote device
1561
1562 * eremote - Pathname hit remote filesystem
1563
1564 * eremoteio - Remote I/O error
1565
1566 * eremoterelease - EREMOTERELEASE
1567
1568 * erofs - Read-only filesystem
1569
1570 * erpcmismatch - Wrong RPC version
1571
1572 * erremote - Object is remote
1573
1574 * eshutdown - Cannot send after socket shutdown
1575
1576 * esocktnosupport - Socket type not supported
1577
1578 * espipe - Invalid seek
1579
1580 * esrch - No such process
1581
1582 * esrmnt - Srmount error
1583
1584 * estale - Stale remote file handle
1585
1586 * esuccess - Error 0
1587
1588 * etime - Timer expired
1589
1590 * etimedout - Connection timed out
1591
1592 * etoomanyrefs - Too many references
1593
1594 * etxtbsy - Text file or pseudo-device busy
1595
1596 * euclean - Structure needs cleaning
1597
1598 * eunatch - Protocol driver not attached
1599
1600 * eusers - Too many users
1601
1602 * eversion - Version mismatch
1603
1604 * ewouldblock - Operation would block
1605
1606 * exdev - Cross-domain link
1607
1608 * exfull - Message tables full
1609
1610 * nxdomain - Hostname or domain name cannot be found
1611
1612Ericsson AB kernel 6.5.2 inet(3)