From 63338250778d2caad08aa3180b372e5260f22aa7 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 31 May 2018 10:58:19 +0200 Subject: [socket-nif-doc] Add preliminary doc for socket The doc now builds. Had to update the code (spec and types) to match. Though, te result is less then stellar. OTP-14831 --- erts/doc/src/Makefile | 6 +- erts/doc/src/ref_man.xml | 3 +- erts/doc/src/socket.xml | 308 +++++++++++++++++++++++++++++++++++++++++++++++ erts/doc/src/specs.xml | 1 + 4 files changed, 315 insertions(+), 3 deletions(-) create mode 100644 erts/doc/src/socket.xml (limited to 'erts/doc') diff --git a/erts/doc/src/Makefile b/erts/doc/src/Makefile index 21aa3db864..1540344fde 100644 --- a/erts/doc/src/Makefile +++ b/erts/doc/src/Makefile @@ -52,7 +52,8 @@ XML_REF3_EFILES = \ erlang.xml \ erl_tracer.xml \ init.xml \ - zlib.xml + zlib.xml \ + socket.xml XML_REF3_FILES = \ driver_entry.xml \ @@ -63,7 +64,8 @@ XML_REF3_FILES = \ erlang.xml \ erts_alloc.xml \ init.xml \ - zlib.xml + zlib.xml \ + socket.xml XML_PART_FILES = \ part.xml diff --git a/erts/doc/src/ref_man.xml b/erts/doc/src/ref_man.xml index 0617463a7b..da099dd5bb 100644 --- a/erts/doc/src/ref_man.xml +++ b/erts/doc/src/ref_man.xml @@ -4,7 +4,7 @@
- 19962016 + 19962018 Ericsson AB. All Rights Reserved. @@ -35,6 +35,7 @@ + diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml new file mode 100644 index 0000000000..9b487172c5 --- /dev/null +++ b/erts/doc/src/socket.xml @@ -0,0 +1,308 @@ + + + + +
+ + 20182018 + Ericsson AB. All Rights Reserved. + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + + socket + + + + + socket.xml +
+ socket + Socket interface. + +

This module provides an API for the socket interface. + It is used to create, delete and manipulate sockets.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Accept a connection on a socket. + +

Accept a connection on a socket.

+

This call is used with connection-based socket types + (stream or seqpacket). It extracs the first pending connection + request for the listen socket and returns the (newly) connected + socket.

+
+
+ + + + Bind a name to a socket. + +

Bind a name to a socket.

+

When a socket is created + (with open), + it has no address assigned to it. bind assigns the + address specified by the Addr argument.

+

The rules used for name binding vary between domains.

+
+
+ + + + Close a socket. + +

Closes the socket.

+
+
+ + + + + Initiate a connection on a socket. + +

This function connects the socket to the address + specied by the Addr argument.

+
+
+ + + + + + + + + + + Get an option on a socket. + +

Get an option on a socket.

+

What properties are valid depend on what kind of socket + it is (domain, type and protocol).

+

When specifying Level as an integer, and therefor + using "native mode", it is *currently* up to the caller to + know how to interpret the result.

+ +

Not all options are valid on all platforms. That is, + even if "we" support an option, that does not mean that the + underlying OS does.

+
+
+ + + + + Listen for connections on a socket. + +

Listen for connections on a socket.

+
+
+ + + + + + Create an endpoint for communication. + +

Creates an endpoint (socket) for communication.

+

For some types there is a default protocol, which will + be used if no protocol is specified:

+ + stream + +

tcp

+
+ dgram + +

udp

+
+ seqpacket + +

sctp

+
+
+
+
+ + + + + + Receive a message from a socket. + +

Receive a message from a socket.

+

There is a special case for the argument Length. + If it is set to zero (0), it means "give me everything you + currently have".

+
+
+ + + + + + + Receive a message from a socket. + +

Receive a message from a socket.

+

This function reads "messages", which means that regardless of + how much we want to read, it returns when we get a message.

+

The MaxSize argument basically defines the size of the + receive buffer. By setting the value to zero (0), the configured + size (setopt) is used.

+

It may be impossible to know what (buffer) size is appropriate + "in advance", and in those cases it may be convenient to use the + (recv) 'peek' flag. When this flag is provided the message is *not* + "consumed" from the underlying buffers, so another recvfrom call + is needed, possibly with a then adjusted buffer size.

+
+
+ + + + + + Send a message on a socket. + +

Send a message on a connected socket.

+
+
+ + + + + Send a message on a socket. + +

Send a message on a socket, to the specified destination.

+
+
+ + + + + + + + + + Set options on a socket. + +

Set options on a socket.

+

What properties are valid depend on what kind of socket + it is (domain, type and protocol).

+ +

Not all options are valid on all platforms. That is, + even if "we" support an option, that does not mean that the + underlying OS does.

+ +

Sockets are set 'non-blocking' when created, so this option + is *not* available (as it would adversely effect the Erlang VM + to set a socket 'blocking').

+
+
+ + + + Shut down part of a full-duplex connection. + +

Shut down all or part of a full-duplex connection.

+
+
+ +
+
+ diff --git a/erts/doc/src/specs.xml b/erts/doc/src/specs.xml index ed6be650e5..4f6951a44b 100644 --- a/erts/doc/src/specs.xml +++ b/erts/doc/src/specs.xml @@ -4,5 +4,6 @@ + -- cgit v1.2.3 From 9e0acc8f442549f1f5ee4271816cbfbeb25d8719 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 7 Jun 2018 11:03:27 +0200 Subject: [socket-nif-doc] Fixed socket type and function open The doc for type socket was missing (as it is opaque), so instead its replaced with a simple text referring to the functions open and accept. The open function missed a spec (for open/2), the text for default protocol needed some omrpvement and finally the Extra argument needed explaining. --- erts/doc/src/socket.xml | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 9b487172c5..d0a316c4de 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -47,7 +47,11 @@ - + socket() +

As returned by + open/2,3,4 and + accept/1,2.

+
@@ -134,7 +138,7 @@

Bind a name to a socket.

When a socket is created - (with open), + (with open), it has no address assigned to it. bind assigns the address specified by the Addr argument.

The rules used for name binding vary between domains.

@@ -199,22 +203,18 @@ Create an endpoint for communication.

Creates an endpoint (socket) for communication.

-

For some types there is a default protocol, which will +

For some types there is a default protocol, which will be used if no protocol is specified:

- - stream - -

tcp

-
- dgram - -

udp

-
- seqpacket - -

sctp

-
-
+ + +

stream: tcp

+

dgram: udp

+

seqpacket: sctp

+
+ +

The Extra argument is intended for "obscure" options. + Currently the only supported option is netns, which + is only supported on the linux platform.

@@ -282,8 +282,9 @@ Set options on a socket.

Set options on a socket.

-

What properties are valid depend on what kind of socket - it is (domain, type and protocol).

+

What properties are valid depend both on Level and on + what kind of socket it is (domain, type and + protocol).

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the -- cgit v1.2.3 From 70b74f57a360c2b2a1edfe46c61d2ea170d73f91 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 7 Jun 2018 17:50:38 +0200 Subject: [socket-nif-doc] More polishing Also added (a very) temporary example. OTP-14831 --- erts/doc/src/socket.xml | 250 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 243 insertions(+), 7 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index d0a316c4de..3efa412b8a 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -149,7 +149,17 @@ Close a socket. -

Closes the socket.

+

Closes the socket.

+ + +

Note that for e.g. protocol = tcp, most implementations + doing a close does not guarantee that any data sent is delivered to + the recipient before the close is detected at the remote side.

+

One way to handle this is to use the + shutdown function + (socket:shutdown(Socket, write)) to signal that no more data is + to be sent and then wait for the read side of the socket to be closed.

+
@@ -159,7 +169,7 @@ Initiate a connection on a socket.

This function connects the socket to the address - specied by the Addr argument.

+ specied by the SockAddr argument.

@@ -171,12 +181,27 @@ + Get an option on a socket. + +

Get an option on a socket.

+

What properties are valid depend both on Level and + on what kind of socket it is (domain, type and + protocol).

+ +

Not all options are valid on all platforms. That is, + even if "we" support an option, that does not mean that the + underlying OS does.

+
+ + + Get an option on a socket.

Get an option on a socket.

-

What properties are valid depend on what kind of socket - it is (domain, type and protocol).

+

What properties are valid depend both on Level and + on what kind of socket it is (domain, type and + protocol).

When specifying Level as an integer, and therefor using "native mode", it is *currently* up to the caller to know how to interpret the result.

@@ -241,12 +266,12 @@

Receive a message from a socket.

This function reads "messages", which means that regardless of how much we want to read, it returns when we get a message.

-

The MaxSize argument basically defines the size of the +

The BufSz argument basically defines the size of the receive buffer. By setting the value to zero (0), the configured - size (setopt) is used.

+ size (setopt with Level = otp) is used.

It may be impossible to know what (buffer) size is appropriate "in advance", and in those cases it may be convenient to use the - (recv) 'peek' flag. When this flag is provided the message is *not* + (recv) 'peek' flag. When this flag is provided, the message is *not* "consumed" from the underlying buffers, so another recvfrom call is needed, possibly with a then adjusted buffer size.

@@ -305,5 +330,216 @@
+
+ Examples + +

TBD: Need to implement a receiver process in order to be able to + implement active!

+

x_tcp.erl:

+ +listen(Addr, Port) -> + try + begin + Socket = case socket:open(inet, stream, tcp) of + {ok, Socket} -> + Socket; + {error, _} = OERROR -> + throw(OERROR) + end, + SockAddr = #in4_sockaddr{port = Port, + addr = Addr}, + ok = case socket:bind(Socket, SockAddr) of + ok -> + ok; + {error, _} = BERROR -> + throw(BERROR) + end, + case socket:listen(Socket, 10) of + ok -> + {ok, Socket}; + {error, _} = LERROR -> + throw(LERROR) + end + end + catch + throw:ERROR -> + ERROR +end. + + + +connect(Addr, Port) -> + try + begin + Socket = case socket:open(inet, stream, tcp) of + {ok, Socket} -> + Socket; + {error, _} = OERROR -> + throw(OERROR) + end, + BSockAddr = #in4_sockaddr{port = 0, + addr = any}, + ok = case socket:bind(Socket, BSockAddr) of + ok -> + ok; + {error, _} = BERROR -> + throw(BERROR) + end, + CSockAddr = #in4_sockaddr{port = Port, + addr = Addr}, + Socket = case socket:connect(Socket, CSockAddr) of + {ok, Sock} -> + Sock; + {error, _} = CERROR -> + throw(CERROR) + end, + case start_receiver(Socket) of + {ok, Pid} -> + ok = socket:ts_add(Socket, receiver, Pid), + {ok, Socket}; + {error, _} = RERROR -> + socket:close(Socket), + throw(RERROR) + end + end + catch + throw:ERROR -> + ERROR +end. + + + +accept(LSocket) -> + case socket:accept(LSocket) of + {ok, Socket} -> + case start_receiver(Socket) of + {ok, Pid} -> + ok = socket:ts_add(Socket, receiver, Pid), + {ok, Socket}; + {error, _} = RERROR -> + socket:close(Socket), + throw(RERROR) + end, + {error, _} = AERROR -> + AERROR + end. + + + +send(Socket, Data) -> + socket:send(Socket, Data). + + + +setopt(Socket, controlling_process = Item, Pid) when is_pid(Pid) -> + case socket:setopt(Socket, otp, Item, Pid) of + ok -> + {ok, Receiver} = socket:ts_get(Socket, receiver), + update_receiver(Receiver, {controlling_process, Pid), + ok; + {error, _} = ERROR -> + ERROR + end; +setopt(Socket, active, Active) -> + {ok, Receiver} = socket:ts_get(Socket, receiver), + receiver_active(Receiver, Active), + ok; +%% This is just to indicate that there will be more options +%% that needs to be handled +setopt(Socket, Item, Pid) when is_pid(Pid) -> + socket:setopt(Socket, which_level(Item), Item, Pid). + + +

The receiver process:

+ +start_receiver(Socket) -> + CtrlProc = self(), + Ref = make_ref(), + Receiver = proc_lib:spawn_link(fun() -> receiver_init(CtrlProc, Ref) end), + receive + {?MODULE, started, Ref} -> + Receiver ! {?MODULE, receiver, Ref, Sock, true}, + unlink(Receiver), + {ok, Receiver}; + {'EXIT', Receiver, Reason} -> + {error, Reason} + end. + +receiver_active(Receiver, Active) + when (Active =:= false) orelse + (Active =:= true) orelse + (Active =:= once) orelse + is_integer(Active) -> + Receiver ! {?MODULE, active, What}. + +receiver_update(Receiver, What) -> + Ref = make_ref(), + Receiver ! {?MODULE, receiver_update, Ref, What}, + receive + {?MODULE, receiver_upadate, Ref, Result} -> + Result + end. + +-record(receiver, {sock :: socket:socket(), + ctrl :: pid(), + num_packages :: infinity | non_neg_ineteger()}). + +receiver_init(Pid, Ref) -> + receive + {?MODULE, receiver, Ref, stop} -> + i("received stop"), + exit(normal); + + {?MODULE, receiver, Ref, Sock, InitialMode} -> + i("received socket: ~p", [Sock]), + NumPackages = mode2pkgcount(InitialMode), + receiver(#receiver{sock = Sock, ctrl = Pid}) + end. + +mode2pkgcount(true) -> + infinity; +mode2pkgcount(false) -> + 0; +mode2pkgcount(N) when is_integer(N) andalso (N >= 0) -> + N. + +receiver(#receiver{num_packages = 0} = State) -> + receive + {?MODULE, active, false} -> + receiver(State); + {?MODULE, active, true} -> + receiver(State#receiver{num_packages = infinity}); + {?MODULE, active, once} -> + receiver(State#receiver{num_packages = 1}); + {?MODULE, active, N} when (N > 0) -> + receiver(State#receiver{num_packages = N}) + end; +receiver(#receiver{num_packages = N, sock = Sock, ctrl = Pid} = State) -> + case socket:recv(Sock, 0) of + {ok, Package} when size(Package) > 0 -> + Pid ! {tcp, Sock, Packege}, + case next_active(N) of + 0 -> + Pid ! {tcp_passive, Sock}, + receiver(State#{num_packages = 0}); + NextN -> + receiver(State#{num_packages = NextN}) + end; + {ok, Package} when size(Package) =:= 0 -> + receiver(State); + + {error, closed} -> + i("closed"), + Pid ! {tcp_closed, Sock}, + exit(normal); + + {error, Reason} -> + i("error: ~p", [Reason]), + Pid ! {tcp_error, Sock, Reason}, + exit(normal) + end. + + +
-- cgit v1.2.3 From eacb95d88db1e1123d17288e71835b457bcf4016 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 4 Jul 2018 18:37:32 +0200 Subject: [socket-doc-nif] Updated documentation Updated the documentation of recv, recvfrom, send and sendto. Also added doc for functions peername and sockname. OTP-14831 --- erts/doc/src/socket.xml | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 3efa412b8a..6f116abca9 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -63,13 +63,16 @@
- + - + - + + + + @@ -244,8 +247,18 @@ + + Get name of connected socket peer. + +

Returns the address of the peer connected to the socket.

+
+
+ + + - + + Receive a message from a socket. @@ -259,7 +272,9 @@ - + + + Receive a message from a socket. @@ -279,7 +294,8 @@ - + + Send a message on a socket. @@ -288,6 +304,7 @@ + Send a message on a socket. @@ -329,6 +346,14 @@ + + + Get socket name. + +

Returns the current address to which the socket is bound.

+
+
+
Examples -- cgit v1.2.3 From 44cfb3d222ba4d20607af7cc654746f84ece3989 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 19 Jun 2018 12:20:21 +0200 Subject: [socket-nif] Add doc for net module and some cleanup Added doc for the net module. Also some socket-nif cleanup. OTP-14831 --- erts/doc/src/Makefile | 6 ++- erts/doc/src/net.xml | 126 +++++++++++++++++++++++++++++++++++++++++++++++ erts/doc/src/ref_man.xml | 1 + erts/doc/src/specs.xml | 1 + 4 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 erts/doc/src/net.xml (limited to 'erts/doc') diff --git a/erts/doc/src/Makefile b/erts/doc/src/Makefile index 1540344fde..9a2750b751 100644 --- a/erts/doc/src/Makefile +++ b/erts/doc/src/Makefile @@ -53,7 +53,8 @@ XML_REF3_EFILES = \ erl_tracer.xml \ init.xml \ zlib.xml \ - socket.xml + socket.xml \ + net.xml XML_REF3_FILES = \ driver_entry.xml \ @@ -65,7 +66,8 @@ XML_REF3_FILES = \ erts_alloc.xml \ init.xml \ zlib.xml \ - socket.xml + socket.xml \ + net.xml XML_PART_FILES = \ part.xml diff --git a/erts/doc/src/net.xml b/erts/doc/src/net.xml new file mode 100644 index 0000000000..c022fee4f7 --- /dev/null +++ b/erts/doc/src/net.xml @@ -0,0 +1,126 @@ + + + + +
+ + 20182018 + Ericsson AB. All Rights Reserved. + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + + net + + + + + net.xml +
+ net + Network interface. + +

This module provides an API for the network interface.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get hostname. + +

Returns the name of the current host.

+
+
+ + + + + Address-to-name transaltion. + +

Address-to-name translation in a protocol-independant manner.

+

This function is the inverse of + getaddrinfo. + It converts a socket address to a corresponding host and service.

+
+
+ + + + + + + Network address and service transation. + +

Network address and service translation.

+

This function is the inverse of + getnameinfo. + It converts host and service to a corresponding socket address.

+

One of the Host and Service may be undefined + but not both.

+
+
+ + + + Mappings between network interface names and indexes. + +

Mappings between network interface names and indexes.

+
+
+ + + + Mappings between network interface index and names. + +

Mappings between network interface index and names.

+
+
+ + + + Get network interface names and indexes. + +

Get network interface names and indexes.

+
+
+ +
+ +
+ diff --git a/erts/doc/src/ref_man.xml b/erts/doc/src/ref_man.xml index da099dd5bb..ccbafb1530 100644 --- a/erts/doc/src/ref_man.xml +++ b/erts/doc/src/ref_man.xml @@ -36,6 +36,7 @@ + diff --git a/erts/doc/src/specs.xml b/erts/doc/src/specs.xml index 4f6951a44b..6c12f619b1 100644 --- a/erts/doc/src/specs.xml +++ b/erts/doc/src/specs.xml @@ -5,5 +5,6 @@ + -- cgit v1.2.3 From 9b5560dbe50c377c8fc9b6a0c0c7b6c2dcf9f0de Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 11 Jul 2018 11:49:58 +0200 Subject: [socket-doc-nif] Preliminary socket option table Added a commented out (preliminary) table in the getopt function for the socket level. The table is not included (atleast) in the man page, so there is no point in including it yet. But since its table(s) of all socket options (one for each level) we need comprehensive tables "somewhere", but where... OTP-14831 --- erts/doc/src/socket.xml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 6f116abca9..2681910a72 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -119,6 +119,9 @@ + + + @@ -194,6 +197,50 @@

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the underlying OS does.

+ + -- cgit v1.2.3 From 0694dfbc731c109fa19bacdc86fe661f14bc1a12 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 17 Jul 2018 16:43:34 +0200 Subject: [socket-doc-nif] Add preliminary users guide Added a very preliminary users guide. Currently where we place the socket option tables. OTP-14831 --- erts/doc/src/Makefile | 1 + erts/doc/src/part.xml | 1 + erts/doc/src/socket_usage.xml | 451 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 453 insertions(+) create mode 100644 erts/doc/src/socket_usage.xml (limited to 'erts/doc') diff --git a/erts/doc/src/Makefile b/erts/doc/src/Makefile index 9a2750b751..bd2528c536 100644 --- a/erts/doc/src/Makefile +++ b/erts/doc/src/Makefile @@ -82,6 +82,7 @@ XML_CHAPTER_FILES = \ driver.xml \ absform.xml \ inet_cfg.xml \ + socket_usage.xml \ erl_ext_dist.xml \ erl_dist_protocol.xml \ communication.xml \ diff --git a/erts/doc/src/part.xml b/erts/doc/src/part.xml index 05e9a24af8..f0b8a00b90 100644 --- a/erts/doc/src/part.xml +++ b/erts/doc/src/part.xml @@ -42,6 +42,7 @@ + diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml new file mode 100644 index 0000000000..b4880c3989 --- /dev/null +++ b/erts/doc/src/socket_usage.xml @@ -0,0 +1,451 @@ + + + + +
+ + 20182018 + Ericsson AB. All Rights Reserved. + + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + + Socket Usage + Micael Karlberg + + 2018-07-17 + PA1 + socket_usage.xml +
+ +
+ Introduction +

The socket interface (module) is basically an "thin" layer on top of + the OS socket interface. It is assumed that, unless you have special needs, + gen_[tcp|udp|sctp] should be sufficent.

+
+ +
+ Socket Options + +

Options for level otp:

+ + + Option Name + Value Type + Set + Get + Other + + + debug + boolean() + yes + yes + none + + + iow + boolean() + yes + yes + none + + + controlling_process + pid() + yes + yes + none + +
+ +

Options for level socket:

+ + + Option Name + Value Type + Set + Get + Other + + + acceptcon + boolean() + no + yes + none + + + bindtodevice + string() + yes + yes + none + + + broadcast + boolean() + yes + yes + type = dgram + + + debug + integer() + yes + yes + may require admin capability + + + domain + domain() + no + yes + none + + + dontroute + boolean() + yes + yes + none + + + keepalive + boolean() + yes + yes + none + + + linger + abort | linger() + yes + yes + none + + + oobinline + boolean() + yes + yes + none + + + peep_off + integer() + yes + yes + domain = local (unix) + + + priority + integer() + yes + yes + none + + + protocol + protocol() + no + yes + none + + + rcvbuf + integer() + yes + yes + none + + + reuseaddr + boolean() + yes + yes + none + + + reuseport + boolean() + yes + yes + domain = inet | inet6 + + + sndbuf + integer() + yes + yes + none + +
+ +

Options for level ip:

+ + + Option Name + Value Type + Set + Get + Other + + + add_membership + ip_mreq() + yes + no + none + + + add_source_membership + ip_mreq_source() + yes + no + none + + + block_source + ip_mreq_source() + yes + no + none + + + drop_membership + ip_mreq() + yes + no + none + + + drop_source_membership + ip_mreq_source() + yes + no + none + + + minttl + integer() + yes + yes + type = raw + + + mtu + integer() + no + yes + type = raw + + + mtu_discover + ip_mtu_discover() + yes + yes + none + + + multicast_all + boolean() + yes + yes + none + + + multicast_if + any | ip4_address() + yes + yes + none + + + multicast_loop + boolean() + yes + yes + none + + + multicast_ttl + 0..255 + yes + yes + none + + + nodefrag + boolean() + yes + yes + type = raw + + + recvif + boolean() + yes + yes + type = dgram | raw + + + recvttl + boolean() + yes + yes + type =/= stream + + + router_alert + integer() + yes + yes + type = raw + + + tos + ip_tos() + yes + yes + none + + + tos + integer() + yes + yes + none + + + unblock_source + ip_mreq_source() + yes + no + none + +
+ +

Options for level ipv6:

+ + + Option Name + Value Type + Set + Get + Other + + + add_membership + ipv6_mreq() + yes + no + none + + + drop_membership + ipv6_mreq() + yes + no + none + + + hoplimit + boolean() + yes + no + type = dgram | raw + +
+ +

Options for level tcp:

+ + + Option Name + Value Type + Set + Get + Other + + + congestion + string() + yes + yes + none + + + maxseg + integer() + yes + yes + type = stream, protocol = tcp + + + nodelay + boolean() + yes + yes + type = stream, protocol = tcp + +
+ +

Options for level udp:

+ + + Option Name + Value Type + Set + Get + Other + + + cork + boolean() + yes + yes + type = dgram, protocol = udp + +
+ +

Options for level sctp:

+ + + Option Name + Value Type + Set + Get + Other + + + autoclose + integer() + yes + yes + protocol = sctp + + + nodelay + boolean() + yes + yes + protocol = sctp + +
+ +
+
+ -- cgit v1.2.3 From ebd626e7b4259bdfb4ddb34ce2d298d0feb0a1c8 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 18 Jul 2018 11:33:50 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option mtu Added support for the VPv6 socket option MTU. OTP-14831. --- erts/doc/src/socket_usage.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index b4880c3989..cdd98090e8 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -369,6 +369,20 @@ no type = dgram | raw + + mtu + boolean() + yes + yes + Get: Only after the socket has been connected + + + v6only + boolean() + yes + no + none +

Options for level tcp:

-- cgit v1.2.3 From 1a3aca0a849af0bae994c9cf89de0dcfe7b310c2 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 18 Jul 2018 12:05:00 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option mtu_discover Added support for the VPv6 socket option MTU_DISCOVER. OTP-14831. --- erts/doc/src/socket_usage.xml | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index cdd98090e8..247cd0eccb 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -145,7 +145,7 @@ none - peep_off + peek_off integer() yes yes @@ -255,7 +255,7 @@ mtu_discover - ip_mtu_discover() + ip_pmtudisc() yes yes none @@ -376,6 +376,13 @@ yes Get: Only after the socket has been connected + + mtu_discover + ipv6_pmtudisc() + yes + yes + none + v6only boolean() @@ -406,14 +413,14 @@ integer() yes yes - type = stream, protocol = tcp + none nodelay boolean() yes yes - type = stream, protocol = tcp + none @@ -431,7 +438,7 @@ boolean() yes yes - type = dgram, protocol = udp + none @@ -449,14 +456,14 @@ integer() yes yes - protocol = sctp + none nodelay boolean() yes yes - protocol = sctp + none -- cgit v1.2.3 From d28129b7098bce154264937862fcdafb21541433 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 19 Jul 2018 14:00:42 +0200 Subject: [socket-nif] Add support for socket (level sctp) option events Added support for the SCTP option EVENTS. OTP-14831 --- erts/doc/src/socket.xml | 21 ++++++++++++++++++--- erts/doc/src/socket_usage.xml | 7 +++++++ 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 2681910a72..4ecf35b8ed 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -122,6 +122,21 @@ + + + + + + + + + + + + + + + @@ -132,9 +147,9 @@

Accept a connection on a socket.

This call is used with connection-based socket types - (stream or seqpacket). It extracs the first pending connection - request for the listen socket and returns the (newly) connected - socket.

+ (stream or seqpacket). It extracs the first pending + connection request for the listen socket and returns the (newly) + connected socket.

diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 247cd0eccb..1d7b98d1a3 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -458,6 +458,13 @@ yes none + + events + sctp_event_subscribe() + yes + no + none + nodelay boolean() -- cgit v1.2.3 From f0a2e68a31ac585780ad05f777f1b7551770420e Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 19 Jul 2018 14:36:34 +0200 Subject: [socket-nif] Add support for socket (level sctp) option disable_fragments Added support for the SCTP option DISABLE_FRAGMENTS. OTP-14831 --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 1d7b98d1a3..9f25e2e9b9 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -458,6 +458,13 @@ yes none + + disable_fragments + boolean() + yes + yes + none + events sctp_event_subscribe() -- cgit v1.2.3 From 7a5b320b5bb5ec45b21839005e8538172908fb57 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 19 Jul 2018 16:39:13 +0200 Subject: [socket-nif] Add (partial) support for socket (level sctp) option associnfo Added support for the SCTP option ASSOCINFO. This option is a bit tricky. As the underlying structure (sctp_assocparams) contains the assoc_id, it begs the question what happens if this option is fetched for: * The own assoc (which means that we might have the assoc id in the descriptor and can initiate that part of the struct accordningly). * Another assoc: From assoc A asks for info with assoc_id set to that of assoc B. * The "owning" endpoint. * Another endpoint (an endpoint to which the assoc does not belong). So, if the user calls socket:[getopt|setopt] for an association socket, shall we require that the assoc_id field is set to -1? Or not set at all and therefor filled in automatically by the nif-code? And, if the user calls socket:[getopt|setopt] for an endpoint socket, shall we require that the assoc_id field is set to a valid id? Or shall it not be allowed? Questions, questions... OTP-14831 --- erts/doc/src/socket.xml | 3 +++ erts/doc/src/socket_usage.xml | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 4ecf35b8ed..3e8e7af5c6 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -137,6 +137,9 @@ + + + diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 9f25e2e9b9..60cb424cde 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -451,9 +451,16 @@ Get Other + + associnfo + sctp_assocparams() + yes + yes + none + autoclose - integer() + non_neg_integer() yes yes none -- cgit v1.2.3 From 6bb60f1fecef368991806e25a0022c63b8650f39 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 19 Jul 2018 17:34:15 +0200 Subject: [socket-nif] Add (partial) support for socket (level sctp) option rtoinfo Added support for the SCTP option RTOINFO. We have the same questions for this option as for ASSOCINFO. Maybe the assoc field shall be made 'out' only (that is, it will be ignored for setopt). The assoc id used will be that which is stored in the descriptor (how do we get it to begin with?). Questions, questions... OTP-14831 --- erts/doc/src/socket.xml | 3 +++ erts/doc/src/socket_usage.xml | 14 ++++++++++++++ 2 files changed, 17 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 3e8e7af5c6..f6b25c8563 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -140,6 +140,9 @@ + + + diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 60cb424cde..1e325016ff 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -49,6 +49,13 @@ Get Other + + assoc_id + integer() + no + yes + type = seqpacket, protocol = sctp, is an association + debug boolean() @@ -486,6 +493,13 @@ yes none + + rtoinfo + sctp_rtoinfo() + yes + yes + none +
-- cgit v1.2.3 From 08ce39bbc2cd3006475c87807042c2d08a68736f Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 19 Jul 2018 17:54:14 +0200 Subject: [socket-nif] Add support for socket (level sctp) option maxseg Added support for the SCTP option MAXSEG. OTP-14831 --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 1e325016ff..21f5d17e84 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -486,6 +486,13 @@ no none + + maxseg + non_neg_integer() + yes + yes + none + nodelay boolean() -- cgit v1.2.3 From bd36af21717b138c91724128e592b3fc587bb07a Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 20 Jul 2018 10:10:28 +0200 Subject: [socket-nif] Add support for socket (level sctp) option initmsg Added support for the SCTP option INITMSG. OTP-14831 --- erts/doc/src/socket.xml | 3 +++ erts/doc/src/socket_usage.xml | 7 +++++++ 2 files changed, 10 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index f6b25c8563..fe23eaa138 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -140,6 +140,9 @@ + + + diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 21f5d17e84..e90e682e39 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -486,6 +486,13 @@ no none + + initmsg + sctp_initmsg() + yes + yes + none + maxseg non_neg_integer() -- cgit v1.2.3 From 3f1d17f3031b71ca6ff1f8e051859ad55e55822b Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 20 Jul 2018 12:28:19 +0200 Subject: [socket-nif] Add support for socket (level socket) option(s) [rcv|snd]timeo Added support for socket level socket option RCVTIMEO and SNDTIMEO. These are both a little strange, at least on linux. See the man pages for more info. OTP-14831 --- erts/doc/src/socket.xml | 9 +++++++++ erts/doc/src/socket_usage.xml | 18 ++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index fe23eaa138..14a21823b8 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -116,6 +116,9 @@ + + + @@ -146,6 +149,12 @@ + + + + + + diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index e90e682e39..221561c3e2 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -114,7 +114,7 @@ integer() yes yes - may require admin capability + require admin capability domain @@ -174,7 +174,14 @@ rcvbuf - integer() + non_neg_integer() + yes + yes + none + + + rcvtimeo + timeval() yes yes none @@ -200,6 +207,13 @@ yes none + + sndtimeo + timeval() + yes + yes + none +

Options for level ip:

-- cgit v1.2.3 From 75498c0dd7682bae7787c4e2cd8d2680fa2b9c45 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 20 Jul 2018 13:00:22 +0200 Subject: [socket-nif] Add support for socket (level socket) option(s) [rcv|snd]lowat Added support for socket level socket option RCVLOWAT and SNDLOWAT. These are both a little strange, at least on Linux. See the man pages for more info. For instance, sndlowat cannot be set on Linux. OTP-14831 --- erts/doc/src/socket_usage.xml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 221561c3e2..9ea585694d 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -179,6 +179,13 @@ yes none + + rcvlowat + non_neg_integer() + yes + yes + none + rcvtimeo timeval() @@ -202,11 +209,18 @@ sndbuf - integer() + non_neg_integer() yes yes none + + sndlowat + non_neg_integer() + yes + yes + not changeable on Linux + sndtimeo timeval() -- cgit v1.2.3 From 84f62ae80dd08874d0d5fbedc532605394e897c1 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 20 Jul 2018 14:01:14 +0200 Subject: [socket-nif] Add support for socket (level socket) option timestamp Added support for socket level socket option TIMESTAMP. OTP-14831 --- erts/doc/src/socket_usage.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 9ea585694d..c875ecd6f0 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -228,6 +228,20 @@ yes none + + timestamp + boolean() + yes + yes + none + + + type + type() + no + yes + none +

Options for level ip:

-- cgit v1.2.3 From 1c26ae984a79224ce64b40dbc7239bf9721bb096 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 20 Jul 2018 15:14:06 +0200 Subject: [socket-nif] Add support for socket (level ip) option freebind Added support for ip level socket option FREEBIND. Note that there is an option available on FreeBSD called IP_BINDANY, which seems to have similar properties (FREEBIND is *not* available on FreeBSD). There are some restrictions for this option though (which is not mentioned in the Linux man page). OTP-14831 --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index c875ecd6f0..a286171a1b 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -288,6 +288,13 @@ no none + + freebind + boolean() + yes + yes + none + minttl integer() -- cgit v1.2.3 From 31ef72ceda0bf5bba902bf18f3b445950516d6af Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 23 Jul 2018 10:57:25 +0200 Subject: [socket-nif] Add support for socket (level ip) option recvopts Added support for ip level socket option RECVOPTS. OTP-14831 --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index a286171a1b..eb1cbf6984 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -358,6 +358,13 @@ yes type = dgram | raw + + recvopts + boolean() + yes + yes + type =/= stream + recvttl boolean() -- cgit v1.2.3 From 2f99a47953404a18965fe6fe434593ee851e8677 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 23 Jul 2018 14:26:25 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option multicast_hops Added support for the IPv6 socket option MULTICAST_HOPS. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index eb1cbf6984..4f18471eb3 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -446,6 +446,13 @@ yes none + + multicast_hops + default | uint8() + yes + yes + none + v6only boolean() -- cgit v1.2.3 From c077834b1465a8285f0c18e1d164c812aaadac9c Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 23 Jul 2018 15:02:39 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option multicast_if Added support for the IPv6 socket option MULTICAST_IF. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 4f18471eb3..f9e094b11a 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -453,6 +453,13 @@ yes none + + multicast_if + integer() + yes + yes + type = dgram | raw + v6only boolean() -- cgit v1.2.3 From 4d14b84183c3c17f0ec03bf3631f1fd8575f07b9 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 23 Jul 2018 17:36:16 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option multicast_loop Added support for the IPv6 socket option MULTICAST_LOOP. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index f9e094b11a..af21806243 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -460,6 +460,13 @@ yes type = dgram | raw + + multicast_loop + boolean() + yes + yes + none + v6only boolean() -- cgit v1.2.3 From de82310c32063b8556add3fe7cf62b26eef27841 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 23 Jul 2018 18:26:42 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option recvpktinfo Added support for the IPv6 socket option RECVPKTINFO. This option is called PKTINFO on FreeBSD, so that value will also be accepted. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index af21806243..78662e7d0d 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -467,6 +467,13 @@ yes none + + recvpktinfo | pktinfo + boolean() + yes + yes + type = dgram | raw + v6only boolean() -- cgit v1.2.3 From d7ca5ba9d8a7f094037878acfecb52b0bfbacc2e Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 24 Jul 2018 10:25:25 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option rthdr Added support for the IPv6 socket option RTHDR. On FreeBSD this option requires superuser privileges to update. There is no mention of this on linux, but its still not possible to update (einval), so I assume that its the same there. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 78662e7d0d..b3ee38dbcb 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -474,6 +474,13 @@ yes type = dgram | raw + + rthdr + boolean() + yes + yes + type = dgram | raw, requires superuser privileges to update + v6only boolean() -- cgit v1.2.3 From 8b61022bdca354e541380391e3b0b2606f7af3f8 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 24 Jul 2018 11:08:20 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option authhdr & hopopts Added support for the IPv6 socket option(s) AUTHHDR and HOPOPTS. Its possible that the option is AUTHHDR is obsolete. It says so in the include files and when trying to get it (getsockopt) it returns with enoprotoopt. The option HOPOPTS returns with einval when calling setsockopt, so either you need to be a privileged user to update, or its not actually possible to update this option (even though it says nothing about that in the man page. It only talks about set). This is the same behaviour as with RTHDR and HOPLIMIT. On FreeBSD, it says that HOPOPTS requires superuser privileges. Needs furher checking. OTP-14831. --- erts/doc/src/socket_usage.xml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index b3ee38dbcb..b13582dfbc 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -418,6 +418,13 @@ no none + + authhdr + boolean() + yes + yes + type = dgram | raw, obsolete? + drop_membership ipv6_mreq() @@ -429,8 +436,15 @@ hoplimit boolean() yes - no - type = dgram | raw + yes + type = dgram | raw, requires superuser privileges to update + + + hopopts + boolean() + yes + yes + type = dgram | raw, requires superuser privileges to update mtu -- cgit v1.2.3 From 9ca6de6efbe844bcf7dc996cfcf51bcd50325007 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 24 Jul 2018 11:49:12 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option dstopts Added support for the IPv6 socket option(s) DSTOPTS. The option returns with einval when calling setsockopt, so either you need to be a privileged user to update, or its not actually possible to update this option (even though it says nothing about that in the man page. It only talks about set). This is the same behaviour as with RTHDR and HOPLIMIT. On FreeBSD, it says that HOPOPTS requires superuser privileges. Needs furher checking. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index b13582dfbc..87b44f139f 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -432,6 +432,13 @@ no none + + dstopts + boolean() + yes + yes + type = dgram | raw, requires superuser privileges to update + hoplimit boolean() -- cgit v1.2.3 From e54642b537177941ff361b1eebdec10e02cfc22d Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 24 Jul 2018 12:05:00 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option flowinfo Added support for the IPv6 socket option(s) FLOWINFO. The option returns with einval when calling setsockopt, so either you need to be a privileged user to update, or its not actually possible to update this option (even though it says nothing about that in the man page. It only talks about set). This is the same behaviour as with DSTOPTS. Needs furher checking. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 87b44f139f..09a65c7152 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -439,6 +439,13 @@ yes type = dgram | raw, requires superuser privileges to update + + flowinfo + boolean() + yes + yes + type = dgram | raw, requires superuser privileges to update + hoplimit boolean() -- cgit v1.2.3 From b598160c2f1162658ea948284aee5b53951a3b9e Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 24 Jul 2018 12:29:22 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option unicast_hops Added support for the IPv6 socket option UNICAST_HOPS. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 09a65c7152..383aebdab1 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -509,6 +509,13 @@ yes type = dgram | raw, requires superuser privileges to update + + unicast_hops + default | uint8() + yes + yes + none + v6only boolean() -- cgit v1.2.3 From 7d5b6e7bf640eb5d64679e3bf7b440b8e21e3a4d Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 24 Jul 2018 15:03:36 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option router_alert Added support for the IPv6 socket option ROUTER_ALERT. Only supported for raw sockets. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 383aebdab1..1423571f5c 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -502,6 +502,13 @@ yes type = dgram | raw + + router_alert + integer() + yes + yes + type = raw + rthdr boolean() -- cgit v1.2.3 From b9237c96b2b86c82bb128625cc532b3528222560 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 24 Jul 2018 16:11:32 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option addrform Added support for the IPv6 socket option ADDRFORM. Only allowed for IPv6 sockets that are connected and bound to a v4-mapped-on-v6 address. OTP-14831. --- erts/doc/src/socket_usage.xml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 1423571f5c..8480af315e 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -411,6 +411,14 @@ Get Other + + addrform + inet + yes + no + allowed only for IPv6 sockets that are connected and bound to a + v4-mapped-on-v6 address + add_membership ipv6_mreq() -- cgit v1.2.3 From 00a2425bde77ddb9ae4c03b8c4e5470064773981 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 24 Jul 2018 16:40:55 +0200 Subject: [socket-nif] Add support for socket (level ip) option recverr Added support for the IP socket option RECVERR. To actually make use of this option, we need the recvmsg function, which we don't have yet. Baby steps. OTP-14831. --- erts/doc/src/socket_usage.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 8480af315e..b791567c22 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -339,7 +339,7 @@ multicast_ttl - 0..255 + uint8() yes yes none @@ -351,6 +351,13 @@ yes type = raw + + recverr + boolean() + yes + yes + none + recvif boolean() -- cgit v1.2.3 From 4e24993aff4c5a0cb2bec96e5499131a660a79f9 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 24 Jul 2018 17:01:46 +0200 Subject: [socket-nif] Add support for socket (level ipv6) option recverr Added support for the IPv6 socket option RECVERR. To actually make use of this option, we need the recvmsg function, which we don't have yet. Baby steps. OTP-14831. --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index b791567c22..30b855f925 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -510,6 +510,13 @@ yes none + + recverr + boolean() + yes + yes + none + recvpktinfo | pktinfo boolean() -- cgit v1.2.3 From 5d9de1cdc46c75117f15f1ab17f017cdb700eb4c Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 25 Jul 2018 11:28:49 +0200 Subject: [socket-nif] Add support for socket (level ip) option msfilter Added support for ip level socket option MSFILTER. This option has not been tested *in any way*... OTP-14831 --- erts/doc/src/socket.xml | 6 ++++++ erts/doc/src/socket_usage.xml | 7 +++++++ 2 files changed, 13 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 14a21823b8..53d1516f1e 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -131,6 +131,12 @@ + + + + + + diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 30b855f925..e7e27629ac 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -302,6 +302,13 @@ yes type = raw + + msfilter + null | ip_msfilter() + yes + no + none + mtu integer() -- cgit v1.2.3 From 587d3a9a76b6ef2c88b850d007d39d34c37b5825 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 25 Jul 2018 12:00:34 +0200 Subject: [socket-nif] Add support for socket (level ip) option hdrincl Added support for ip level socket option HDRINCL. As this option is raw only, it has not yet been tested! OTP-14831 --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index e7e27629ac..2ddd51d1e6 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -295,6 +295,13 @@ yes none + + hdrincl + boolean() + yes + yes + type = raw + minttl integer() -- cgit v1.2.3 From 70a5b8d6a01b91a6044c6a5a0f8ed8919afd509b Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 25 Jul 2018 12:29:41 +0200 Subject: [socket-nif] Add support for socket (level ip) option pktinfo Added support for ip level socket option PKTINFO. This option requires sendmsg and/or recvmsg to actually use, so we cannot test this fully at the moment (although both set and get works). OTP-14831 --- erts/doc/src/socket_usage.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 2ddd51d1e6..443d4edec7 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -365,6 +365,13 @@ yes type = raw + + pktinfo + boolean() + yes + yes + type = dgram + recverr boolean() @@ -408,7 +415,7 @@ none - tos + ttl integer() yes yes -- cgit v1.2.3 From 673367a0c17349a8b57dfad5dbc349c68417c6a5 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 25 Jul 2018 13:07:34 +0200 Subject: [socket-nif] Add support for socket (level ip) option transparent Added support for ip level socket option TRANSPARENT. OTP-14831 --- erts/doc/src/socket_usage.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 443d4edec7..b1fe22b231 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -412,7 +412,14 @@ ip_tos() yes yes - none + may require admin capability + + + transparent + boolean() + yes + yes + require admin capability ttl -- cgit v1.2.3 From cb8877a5561ac64704337441936b62c8c87f8d13 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 25 Jul 2018 14:09:24 +0200 Subject: [socket-nif] Add support for socket (level ip) option retopts Added support for ip level socket option RETOPTS. OTP-14831 --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index b1fe22b231..79cafa0162 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -400,6 +400,13 @@ yes type =/= stream + + retopts + boolean() + yes + yes + type =/= stream + router_alert integer() -- cgit v1.2.3 From 8ed757c8df2df54e19e67ca0a0734cd5a0f9ab23 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 26 Jul 2018 10:10:16 +0200 Subject: [socket-nif] Add support for socket (level ip) option recvorigdstaddr Added support for ip level socket option RECVORIGDSTADDR. This option requires recvmsg to actually use, so we cannot test this fully at the moment (although both set and get works). OTP-14831 --- erts/doc/src/socket_usage.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 79cafa0162..f69aa75820 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -372,6 +372,13 @@ yes type = dgram + + recvdstaddr + boolean() + yes + yes + type = dgram + recverr boolean() @@ -393,6 +400,13 @@ yes type =/= stream + + recvorigdstaddr + boolean() + yes + yes + none + recvttl boolean() -- cgit v1.2.3 From 6b01561dc13a0152f56da0a2c61ad88236f87de7 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 26 Jul 2018 11:07:05 +0200 Subject: [socket-nif] Add support for socket (level ip) option sendsrcaddr Added support for ip level socket option SENDSRCADDR. This option requires sendmsg to actually use, so we cannot test this fully at the moment. OTP-14831 --- erts/doc/src/socket_usage.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index f69aa75820..933341bd35 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -35,6 +35,10 @@

The socket interface (module) is basically an "thin" layer on top of the OS socket interface. It is assumed that, unless you have special needs, gen_[tcp|udp|sctp] should be sufficent.

+

Note that just because we have a documented and described option, + it does not mean that the OS supports it. So its recommended + that the user reads the platform specific documentation for the + option used.

@@ -428,6 +432,13 @@ yes type = raw + + sendsrcaddr + boolean() + yes + yes + none + tos ip_tos() -- cgit v1.2.3 From 90a150771faa3cf01e82919b0c17854de9987783 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Wed, 1 Aug 2018 19:42:32 +0200 Subject: [socket-nif] Processing of more cmsg headers Added processing or more cmsg headers (for more options). Now (also) supports: socket:timestamp. Also various fixes and cleanups. For some reason calling getopt(Sock, 0, {13, int}) (or similar) fails with badarg even though the nif-function (nif_getopt) actually returns a valid value (for instance: {ok, 0}). OTP-14831 --- erts/doc/src/socket.xml | 26 +++++++++++++++++++++++++- erts/doc/src/socket_usage.xml | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 53d1516f1e..2fb922408b 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -120,7 +120,7 @@ - + @@ -137,6 +137,9 @@ + + + @@ -155,6 +158,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 933341bd35..b7459e97fa 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -444,7 +444,7 @@ ip_tos() yes yes - may require admin capability + some high-priority levels may require superuser capability transparent -- cgit v1.2.3 From d8b1eace1cfe3184497752f345e5f6bc5def9769 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 3 Aug 2018 12:33:22 +0200 Subject: [socket-nif] Add preliminary support for sendmsg Added function sendmsg/2,3,4. Actually worked on the first try. Something must be wrong... Still no supported cmsghdr's (only support headers where the data part is already a binary, which therefor does not require any processing). So if the cmsghdrs actually work is unclear. OTP-14831 --- erts/doc/src/socket.xml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 2fb922408b..93a3a8172e 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -402,6 +402,40 @@ + + + + + + + Receive a message from a socket. + +

Receive a message from a socket.

+

This function reads "messages", which means that regardless of + how much we want to read, it returns when we get a message.

+

The message will be delivered in the form of a msghdr(), + which may contain the source address (if socket not connected), + a list of cmsghdr() (depends on what socket options have + been set and what the protocol and platform supports) and + also a set of flags, providing further info about the read .

+ +

The BufSz argument basically defines the size of the + receive buffer. By setting the value to zero (0), the configured + size (setopt with Level = otp) is used.

+ +

The CtrlSz argument basically defines the size of the + receive buffer for the control messages. + By setting the value to zero (0), the configured size (setopt + with Level = otp) is used.

+ +

It may be impossible to know what (buffer) size is appropriate + "in advance", and in those cases it may be convenient to use the + (recv) 'peek' flag. When this flag is provided, the message is *not* + "consumed" from the underlying buffers, so another recvmsg call + is needed, possibly with a then adjusted buffer size.

+
+
+ @@ -413,6 +447,21 @@ + + + + + + Send a message on a socket. + +

Send a message on a socket. The destination, if needed (socket not + connected) is provided in the MsgHdr, which also + contains the message to send, The MsgHdr may also contain + an list of optional cmsghdr() (depends on what the protocol and + platform supports).

+
+
+ -- cgit v1.2.3 From 01601a4db44b3adccfbcc07129a4584649252736 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 3 Aug 2018 15:08:30 +0200 Subject: [socket-nif] Add more data types (with doc) and (C) debug Add more debug printouts for the new sendmsg. Also added new (erlang) types with doc. OTP-14831 --- erts/doc/src/socket.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 93a3a8172e..b11b68cba5 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -146,6 +146,9 @@ + + + @@ -179,12 +182,21 @@ + + + + + + + + + -- cgit v1.2.3 From ee2eadd1c61d4237ee4044260665c82edf559228 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 3 Aug 2018 18:55:30 +0200 Subject: [socket-nif] Add support for (recvmsg) control message ipv6_pktinfo Added support for (recvmsg) control message ipv6_pktinfo, for level = ipv6 and type = pktinfo. This is enabled by setting the socket option: recvpktinfo for level ipv6. Not yet tested! OTP-14831 --- erts/doc/src/socket_usage.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index b7459e97fa..9785830637 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -51,7 +51,7 @@ Value Type Set Get - Other + Other Requirements and comments
assoc_id @@ -90,7 +90,7 @@ Value Type Set Get - Other + Other Requirements and comments acceptcon @@ -118,7 +118,7 @@ integer() yes yes - require admin capability + requires admin capability domain @@ -255,7 +255,7 @@ Value Type Set Get - Other + Other Requirements and comments add_membership @@ -451,7 +451,7 @@ boolean() yes yes - require admin capability + requires admin capability ttl @@ -476,7 +476,7 @@ Value Type Set Get - Other + Other Requirements and comments addrform @@ -621,7 +621,7 @@ Value Type Set Get - Other + Other Requirements and comments congestion @@ -653,7 +653,7 @@ Value Type Set Get - Other + Other Requirements and comments cork @@ -671,7 +671,7 @@ Value Type Set Get - Other + Other Requirements and comments associnfo -- cgit v1.2.3 From 929ae46220f402d6f36072c46fe27ba39ad48d1b Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 13 Sep 2018 15:44:21 +0200 Subject: [socket-nif] CMsgHdr and various doc related changes Updated the (send) cmsghdr type and the handling of it (in the nif code). Still not tested! Removed the is_loaded nif function. Tried to get fix the doc build problem (socket.erl *i think*), which causes socket.html generation to fail with: "cannot find module exporting type" To solve this I tried to run dialyzer on preloaded, and ran into problems with enc_setopt_value. Update various specs and types to "solve" this (which did not work). Updated the nif-stub functions to make dialyzer happy. --- erts/doc/src/socket.xml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index b11b68cba5..35f7e8502d 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -176,11 +176,16 @@ + - + + + + @@ -427,7 +432,7 @@ how much we want to read, it returns when we get a message.

The message will be delivered in the form of a msghdr(), which may contain the source address (if socket not connected), - a list of cmsghdr() (depends on what socket options have + a list of cmsghdr_recv() (depends on what socket options have been set and what the protocol and platform supports) and also a set of flags, providing further info about the read .

@@ -466,11 +471,11 @@ Send a message on a socket. -

Send a message on a socket. The destination, if needed (socket not - connected) is provided in the MsgHdr, which also - contains the message to send, The MsgHdr may also contain - an list of optional cmsghdr() (depends on what the protocol and - platform supports).

+

Send a message on a socket. The destination, if needed + (socket not connected) is provided in the MsgHdr, + which also contains the message to send, + The MsgHdr may also contain an list of optional cmsghdr_send() + (depends on what the protocol and platform supports).

@@ -492,6 +497,7 @@ + Set options on a socket.

Set options on a socket.

-- cgit v1.2.3 From 4341dcd7ab14ae8af3d12a30563b5229015e320c Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 27 Sep 2018 12:40:35 +0200 Subject: [socket-nif|doc] SCTP type and sendto Added missing SCTP type (for assoc id) and updated sento doc (missing clauses). OTP-14831 --- erts/doc/src/socket.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 35f7e8502d..e2fd0adc8f 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -146,6 +146,9 @@ + + + @@ -481,7 +484,8 @@ - + + Send a message on a socket. -- cgit v1.2.3 From 0b56a98366fc152c0fa5d5398220ac31866114d5 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 28 Sep 2018 18:34:45 +0200 Subject: [socket-nif|doc] Cleanup and fixed setopt doc Removed some cruft. Also tried, without success, to fix the build issue ("Error file: cannot find module exporting type"). It may be because of a spec-file issue. Finally fixed the setopt doc. It did not have a seperate clause for clause 8 (the fallback clause that takes level and key as integer). --- erts/doc/src/net.xml | 4 +- erts/doc/src/socket.xml | 272 ++++-------------------------------------------- 2 files changed, 23 insertions(+), 253 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/net.xml b/erts/doc/src/net.xml index c022fee4f7..e0c3b4ec73 100644 --- a/erts/doc/src/net.xml +++ b/erts/doc/src/net.xml @@ -75,7 +75,7 @@

Address-to-name translation in a protocol-independant manner.

This function is the inverse of - getaddrinfo. + getaddrinfo. It converts a socket address to a corresponding host and service.

@@ -89,7 +89,7 @@

Network address and service translation.

This function is the inverse of - getnameinfo. + getnameinfo. It converts host and service to a corresponding socket address.

One of the Host and Service may be undefined but not both.

diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index e2fd0adc8f..af7e0ca9c1 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -245,7 +245,8 @@ doing a close does not guarantee that any data sent is delivered to the recipient before the close is detected at the remote side.

One way to handle this is to use the - shutdown function + shutdown + function (socket:shutdown(Socket, write)) to signal that no more data is to be sent and then wait for the read side of the socket to be closed.

@@ -281,49 +282,6 @@ even if "we" support an option, that does not mean that the underlying OS does.

-
@@ -501,6 +459,24 @@ + Set options on a socket. + +

Set options on a socket.

+

What properties are valid depend both on Level and on + what kind of socket it is (domain, type and + protocol).

+ +

Not all options are valid on all platforms. That is, + even if "we" support an option, that does not mean that the + underlying OS does.

+ +

Sockets are set 'non-blocking' when created, so this option + is *not* available (as it would adversely effect the Erlang VM + to set a socket 'blocking').

+
+ + + Set options on a socket. @@ -539,213 +515,7 @@
Examples -

TBD: Need to implement a receiver process in order to be able to - implement active!

-

x_tcp.erl:

- -listen(Addr, Port) -> - try - begin - Socket = case socket:open(inet, stream, tcp) of - {ok, Socket} -> - Socket; - {error, _} = OERROR -> - throw(OERROR) - end, - SockAddr = #in4_sockaddr{port = Port, - addr = Addr}, - ok = case socket:bind(Socket, SockAddr) of - ok -> - ok; - {error, _} = BERROR -> - throw(BERROR) - end, - case socket:listen(Socket, 10) of - ok -> - {ok, Socket}; - {error, _} = LERROR -> - throw(LERROR) - end - end - catch - throw:ERROR -> - ERROR -end. - - - -connect(Addr, Port) -> - try - begin - Socket = case socket:open(inet, stream, tcp) of - {ok, Socket} -> - Socket; - {error, _} = OERROR -> - throw(OERROR) - end, - BSockAddr = #in4_sockaddr{port = 0, - addr = any}, - ok = case socket:bind(Socket, BSockAddr) of - ok -> - ok; - {error, _} = BERROR -> - throw(BERROR) - end, - CSockAddr = #in4_sockaddr{port = Port, - addr = Addr}, - Socket = case socket:connect(Socket, CSockAddr) of - {ok, Sock} -> - Sock; - {error, _} = CERROR -> - throw(CERROR) - end, - case start_receiver(Socket) of - {ok, Pid} -> - ok = socket:ts_add(Socket, receiver, Pid), - {ok, Socket}; - {error, _} = RERROR -> - socket:close(Socket), - throw(RERROR) - end - end - catch - throw:ERROR -> - ERROR -end. - - - -accept(LSocket) -> - case socket:accept(LSocket) of - {ok, Socket} -> - case start_receiver(Socket) of - {ok, Pid} -> - ok = socket:ts_add(Socket, receiver, Pid), - {ok, Socket}; - {error, _} = RERROR -> - socket:close(Socket), - throw(RERROR) - end, - {error, _} = AERROR -> - AERROR - end. - - - -send(Socket, Data) -> - socket:send(Socket, Data). - - - -setopt(Socket, controlling_process = Item, Pid) when is_pid(Pid) -> - case socket:setopt(Socket, otp, Item, Pid) of - ok -> - {ok, Receiver} = socket:ts_get(Socket, receiver), - update_receiver(Receiver, {controlling_process, Pid), - ok; - {error, _} = ERROR -> - ERROR - end; -setopt(Socket, active, Active) -> - {ok, Receiver} = socket:ts_get(Socket, receiver), - receiver_active(Receiver, Active), - ok; -%% This is just to indicate that there will be more options -%% that needs to be handled -setopt(Socket, Item, Pid) when is_pid(Pid) -> - socket:setopt(Socket, which_level(Item), Item, Pid). - - -

The receiver process:

- -start_receiver(Socket) -> - CtrlProc = self(), - Ref = make_ref(), - Receiver = proc_lib:spawn_link(fun() -> receiver_init(CtrlProc, Ref) end), - receive - {?MODULE, started, Ref} -> - Receiver ! {?MODULE, receiver, Ref, Sock, true}, - unlink(Receiver), - {ok, Receiver}; - {'EXIT', Receiver, Reason} -> - {error, Reason} - end. - -receiver_active(Receiver, Active) - when (Active =:= false) orelse - (Active =:= true) orelse - (Active =:= once) orelse - is_integer(Active) -> - Receiver ! {?MODULE, active, What}. - -receiver_update(Receiver, What) -> - Ref = make_ref(), - Receiver ! {?MODULE, receiver_update, Ref, What}, - receive - {?MODULE, receiver_upadate, Ref, Result} -> - Result - end. - --record(receiver, {sock :: socket:socket(), - ctrl :: pid(), - num_packages :: infinity | non_neg_ineteger()}). - -receiver_init(Pid, Ref) -> - receive - {?MODULE, receiver, Ref, stop} -> - i("received stop"), - exit(normal); - - {?MODULE, receiver, Ref, Sock, InitialMode} -> - i("received socket: ~p", [Sock]), - NumPackages = mode2pkgcount(InitialMode), - receiver(#receiver{sock = Sock, ctrl = Pid}) - end. - -mode2pkgcount(true) -> - infinity; -mode2pkgcount(false) -> - 0; -mode2pkgcount(N) when is_integer(N) andalso (N >= 0) -> - N. - -receiver(#receiver{num_packages = 0} = State) -> - receive - {?MODULE, active, false} -> - receiver(State); - {?MODULE, active, true} -> - receiver(State#receiver{num_packages = infinity}); - {?MODULE, active, once} -> - receiver(State#receiver{num_packages = 1}); - {?MODULE, active, N} when (N > 0) -> - receiver(State#receiver{num_packages = N}) - end; -receiver(#receiver{num_packages = N, sock = Sock, ctrl = Pid} = State) -> - case socket:recv(Sock, 0) of - {ok, Package} when size(Package) > 0 -> - Pid ! {tcp, Sock, Packege}, - case next_active(N) of - 0 -> - Pid ! {tcp_passive, Sock}, - receiver(State#{num_packages = 0}); - NextN -> - receiver(State#{num_packages = NextN}) - end; - {ok, Package} when size(Package) =:= 0 -> - receiver(State); - - {error, closed} -> - i("closed"), - Pid ! {tcp_closed, Sock}, - exit(normal); - - {error, Reason} -> - i("error: ~p", [Reason]), - Pid ! {tcp_error, Sock, Reason}, - exit(normal) - end. - - +

TBD

-- cgit v1.2.3 From 1c412c62ba3be17b7a818f264049a7ee7942351e Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 28 Sep 2018 18:40:08 +0200 Subject: [socket-nif] Add support for socket (level otp) buffer options Add support for otp level socket options rcvbuf, rcvctrlbuf and sndctrlbuf. These options define default sizes for these buffers. The 'rcvbuf' is used when receiving messages when calling the recv, recvfrom and recvmsg functions. The 'rcvctrlbuf' is used for the control message header info when calling the recvmsg function. The 'sndctrlbuf' is used for the control message header info when calling the sendmsg function. OTP-14831 --- erts/doc/src/socket_usage.xml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 9785830637..23d0f319f1 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -81,6 +81,27 @@ yes none
+ + rcvbuf + default | pos_integer() + yes + yes + default only valid for set + + + rcvctrlbuf + default | pos_integer() + yes + yes + default only valid for set + + + sndctrlbuf + default | pos_integer() + yes + yes + default only valid for set +

Options for level socket:

-- cgit v1.2.3 From 4b1e1e148a5cc9c19127b61aaa3e15eeeaea6cb2 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 4 Oct 2018 10:06:16 +0200 Subject: [socket-nif] Socket option 'SO_DOMAIN' not avalable on all platforms Internally in the socket module we accessed domain, type and protocol for an open socket. But as it turns out, domain (family) is not actually available as a socket option on all platforms. FreeBSD in this case. So, since we store these values in the socket descriptor anyway, we switch to use these values for our internal use instead. OTP-14831 --- erts/doc/src/socket_usage.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 23d0f319f1..1ea29097c3 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -146,7 +146,7 @@ domain() no yes - none + Not on FreeBSD (for instance) dontroute -- cgit v1.2.3 From ce28d70c686f342fb04fc05e1d00501e7cfbf213 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 9 Oct 2018 16:32:31 +0200 Subject: [socket-nif|doc] Add preliminary doc for the function supports Added preliminary documentation for the function socket:supports/0,1,2,3. It still does not generate proper doc for supports/3 (the last arg, Opt, don't get a type). OTP-14831 --- erts/doc/src/socket.xml | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index af7e0ca9c1..49c14869bf 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -205,6 +205,27 @@ + + + + + + + + + + + + + + + + + + + + + @@ -511,6 +532,34 @@ + + + + + + + + + + + + + + + + + + + + + Report info about what the platform supports. + +

This function intends to retreive information about what the + platform supports. Such as if SCTP is supported. Or which socket + options are supported.

+
+
+
Examples -- cgit v1.2.3 From 741eb8d2d8ba606d81990ef50b2d8b261d47ec81 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 5 Nov 2018 14:47:03 +0100 Subject: [socket-nif|doc] Improved doc for recvmsg and update for sendmsg The API for the sendmsg function has been updated to describe the possible "partial success" of {ok, Remaining}. OTP-14831 --- erts/doc/src/socket.xml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 49c14869bf..ea2fde7dee 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -405,7 +405,8 @@ - + + Receive a message from a socket. @@ -416,7 +417,7 @@ which may contain the source address (if socket not connected), a list of cmsghdr_recv() (depends on what socket options have been set and what the protocol and platform supports) and - also a set of flags, providing further info about the read .

+ also a set of flags, providing further info about the read.

The BufSz argument basically defines the size of the receive buffer. By setting the value to zero (0), the configured @@ -458,6 +459,15 @@ which also contains the message to send, The MsgHdr may also contain an list of optional cmsghdr_send() (depends on what the protocol and platform supports).

+ +

Unlike the send function, + this one sends one message. + This means that if, for whatever reason, its not possible to send the + message in one go, the function will instead return with the + remaining data ({ok, Remaining}). Thereby leaving it + up to the caller to decide what to do (retry with the remaining data + of give up).

+
-- cgit v1.2.3 From 8a820377bb3e2e506cdff6011057d78507544142 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 21 Jan 2019 14:46:07 +0100 Subject: [socket-nif] Add support for otp option fd Add a way to *get* the file descriptor (fd) of a socket. Useful mostly for debugging. OTP-15528 --- erts/doc/src/socket_usage.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 1ea29097c3..401a70992f 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -4,7 +4,7 @@
- 20182018 + 20182019 Ericsson AB. All Rights Reserved. @@ -102,6 +102,13 @@ yes default only valid for set + + fd + integer() + no + yes + none +

Options for level socket:

-- cgit v1.2.3 From 3d166efe4f3ee6a93edf361a9d72633a00fb486f Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 29 Jan 2019 12:41:19 +0100 Subject: [socket-nif] The otp rcvbuf option updated Its now possible to set a rcvbuf (otp) option value of {N :: pos_integer(), BufSz :: pos_integer()}. This value is used for type stream and protocol tcp, when calling the function recv with length = 0 (zero). The second value, BufSz, is the actual size of the receive buffer used when calling the socket recv function, and the first value, N, is the max number of possible reads that will be performed (at most), even if there is more data to read. This is limit the effect of DoS attacks. OTP-15497 --- erts/doc/src/socket_usage.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 401a70992f..756f0dbd44 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -83,10 +83,11 @@ rcvbuf - default | pos_integer() + default | pos_integer() | {pos_integer(), pos_ineteger()} yes yes - default only valid for set + 'default' only valid for set. + The tuple form is only valid for type 'stream' and protocol 'tcp'. rcvctrlbuf -- cgit v1.2.3 From 72b1e75d9bfc7340c3e4a7158cf1c21ae467d52a Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 8 Feb 2019 15:17:56 +0100 Subject: [socket|doc] Add a tiny bit more header text and an example Add a bit more text in the (socket) module description. Also added a (very) basic example. OTP-14831 --- erts/doc/src/socket.xml | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index ea2fde7dee..56737b1a8f 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -33,7 +33,13 @@ Socket interface.

This module provides an API for the socket interface. - It is used to create, delete and manipulate sockets.

+ It is used to create, delete and manipulate sockets, + send and receive data.

+

The idea is that it shall be as "close as possible" to the OS + level socket interface. The only significant addition is that some of + the functions, + e.g. recv/3, + has a timeout argument.

@@ -574,7 +580,34 @@
Examples -

TBD

+ +client(Addr, Port) -> + {ok, Sock} = socket:open(inet, stream, tcp), + ok = socket:bind(Sock, #{family => inet, + port => 0, + addr => any}), + ok = socket:connect(Sock, #{family => inet, + addr => Addr, + port => Port}), + Msg = list_to_binary("hello"), + ok = socket:send(Sock, Msg), + ok = socket:shutdown(Sock, write), + {ok, Msg} = socket:recv(Sock), + ok = socket:close(Sock). + +server(Addr, Port) -> + {ok, LSock} = socket:open(inet, stream, tcp), + ok = socket:bind(LSock, #{family => inet, + port => Port, + addr => Addr}), + ok = socket:listen(LSock), + {ok, Sock} = socket:accept(LSock), + {ok, Msg} = socket:recv(Sock), + ok = socket:send(Sock, Msg), + ok = socket:shutdown(Sock, write), + ok = socket:close(Sock), + ok = socket:close(LSock). +
-- cgit v1.2.3 From 2892deedb43cb3f0e1479f18609584c9d4952dda Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 8 Feb 2019 16:08:09 +0100 Subject: [socket|doc] Add preliminary table caption Add preliminary (option) table captions. OTP-14831 --- erts/doc/src/socket_usage.xml | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 756f0dbd44..4ec31b5296 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -110,6 +110,7 @@ yes none
+ option levels

Options for level socket:

@@ -275,6 +276,7 @@ yes none + socket options

Options for level ip:

@@ -496,6 +498,7 @@ no none + ip options

Options for level ipv6:

@@ -641,6 +644,7 @@ no none + ipv6 options

Options for level tcp:

@@ -673,6 +677,7 @@ yes none + tcp options

Options for level udp:

@@ -691,6 +696,7 @@ yes none + udp options

Options for level sctp:

@@ -758,6 +764,7 @@ yes none + sctp options
-- cgit v1.2.3 From 2b268fb6ac18956a3d5d55eea57fdc461d5ef7bf Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 12 Feb 2019 15:18:07 +0100 Subject: [socket|doc] Fixed links and stuff Corrected linking references (links) to functions. Also added links from getopt/setopt functions to the users guide. Also added some comments to the socket module regarding open with (ready made) descriptor (which is not yet supported). OTP-14831 --- erts/doc/src/socket.xml | 26 ++++++++++++++++++++++---- erts/doc/src/socket_usage.xml | 1 + 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 56737b1a8f..8a68ee3e90 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -4,7 +4,7 @@
- 20182018 + 20182019 Ericsson AB. All Rights Reserved. @@ -55,7 +55,7 @@ socket()

As returned by - open/2,3,4 and + open/2,3,4 and accept/1,2.

@@ -305,6 +305,10 @@ on what kind of socket it is (domain, type and protocol).

+ See the + socket options + chapter of the users guide for more info. +

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the underlying OS does.

@@ -324,6 +328,10 @@ using "native mode", it is *currently* up to the caller to know how to interpret the result.

+ See the + socket options + chapter of the users guide for more info. +

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the underlying OS does.

@@ -398,7 +406,8 @@ how much we want to read, it returns when we get a message.

The BufSz argument basically defines the size of the receive buffer. By setting the value to zero (0), the configured - size (setopt with Level = otp) is used.

+ size (setopt with Level = otp and Key = rcvbuf) + is used.

It may be impossible to know what (buffer) size is appropriate "in advance", and in those cases it may be convenient to use the (recv) 'peek' flag. When this flag is provided, the message is *not* @@ -427,7 +436,8 @@

The BufSz argument basically defines the size of the receive buffer. By setting the value to zero (0), the configured - size (setopt with Level = otp) is used.

+ size (setopt with Level = otp and Key = rcvbuf) + is used.

The CtrlSz argument basically defines the size of the receive buffer for the control messages. @@ -503,6 +513,10 @@ what kind of socket it is (domain, type and protocol).

+ See the + socket options + chapter of the users guide for more info. +

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the underlying OS does.

@@ -522,6 +536,10 @@ what kind of socket it is (domain, type and protocol).

+ See the + socket options + chapter of the users guide for more info. +

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the underlying OS does.

diff --git a/erts/doc/src/socket_usage.xml b/erts/doc/src/socket_usage.xml index 4ec31b5296..e0f006e618 100644 --- a/erts/doc/src/socket_usage.xml +++ b/erts/doc/src/socket_usage.xml @@ -42,6 +42,7 @@
+ Socket Options

Options for level otp:

-- cgit v1.2.3 From 89199d9892e59980f2eca66b561d26cb53f694da Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 12 Feb 2019 17:37:35 +0100 Subject: [socket|doc] Forgot to run xmllint (again) --- erts/doc/src/Makefile | 2 ++ erts/doc/src/socket.xml | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/Makefile b/erts/doc/src/Makefile index fdfd81c2f3..06a8691c0e 100644 --- a/erts/doc/src/Makefile +++ b/erts/doc/src/Makefile @@ -149,6 +149,8 @@ $(INFO_FILE): $(INFO_FILE_SRC) $(ERL_TOP)/make/$(TARGET)/otp.mk debug opt: +ldocs: xmllint local_docs + clean: rm -rf $(HTMLDIR)/* rm -rf $(XMLDIR) diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 8a68ee3e90..05ffc8f074 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -305,9 +305,9 @@ on what kind of socket it is (domain, type and protocol).

- See the +

See the socket options - chapter of the users guide for more info. + chapter of the users guide for more info.

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the @@ -328,9 +328,9 @@ using "native mode", it is *currently* up to the caller to know how to interpret the result.

- See the +

See the socket options - chapter of the users guide for more info. + chapter of the users guide for more info.

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the @@ -513,9 +513,9 @@ what kind of socket it is (domain, type and protocol).

- See the +

See the socket options - chapter of the users guide for more info. + chapter of the users guide for more info.

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the @@ -536,9 +536,9 @@ what kind of socket it is (domain, type and protocol).

- See the +

See the socket options - chapter of the users guide for more info. + chapter of the users guide for more info.

Not all options are valid on all platforms. That is, even if "we" support an option, that does not mean that the -- cgit v1.2.3 From 0f4aff72763d8b49b5b6361970db70111b3cddce Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 18 Feb 2019 16:13:00 +0100 Subject: [socket|net|doc] Fixed broken anchors Fixed broken links to types and functions. OTP-14831 --- erts/doc/src/net.xml | 4 ++-- erts/doc/src/socket.xml | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/net.xml b/erts/doc/src/net.xml index e0c3b4ec73..484c7a5f56 100644 --- a/erts/doc/src/net.xml +++ b/erts/doc/src/net.xml @@ -75,7 +75,7 @@

Address-to-name translation in a protocol-independant manner.

This function is the inverse of - getaddrinfo. + getaddrinfo. It converts a socket address to a corresponding host and service.

@@ -89,7 +89,7 @@

Network address and service translation.

This function is the inverse of - getnameinfo. + getnameinfo. It converts host and service to a corresponding socket address.

One of the Host and Service may be undefined but not both.

diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 05ffc8f074..cf0cde2e68 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -83,6 +83,12 @@ + + + + + + @@ -95,6 +101,12 @@ + + + + + + @@ -476,7 +488,7 @@ The MsgHdr may also contain an list of optional cmsghdr_send() (depends on what the protocol and platform supports).

-

Unlike the send function, +

Unlike the send function, this one sends one message. This means that if, for whatever reason, its not possible to send the message in one go, the function will instead return with the -- cgit v1.2.3 From 99fd1547e6dd22a7ea77d893fb5691353357cf99 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 19 Feb 2019 11:06:29 +0100 Subject: [socket|doc] Fixed IPv6 PKTINFO type Another broken anchor fixed. The type 'ipv6_pktinfo' was not exported nor was it part of the doc. OTP-14831 --- erts/doc/src/socket.xml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index cf0cde2e68..9e8b9cd29f 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -164,6 +164,9 @@ + + + -- cgit v1.2.3 From 24c82c328bf9ee278f67ba05e4f6c89dd1333a59 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 21 Feb 2019 11:10:45 +0100 Subject: [socket|net|doc] Add 'since' tag Add 'since' tag to the module and func elements. OTP-14831 --- erts/doc/src/net.xml | 20 +++--- erts/doc/src/socket.xml | 158 ++++++++++++++++++++++++------------------------ 2 files changed, 89 insertions(+), 89 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/net.xml b/erts/doc/src/net.xml index 484c7a5f56..bd85594c98 100644 --- a/erts/doc/src/net.xml +++ b/erts/doc/src/net.xml @@ -29,7 +29,7 @@ net.xml

- net + net Network interface.

This module provides an API for the network interface.

@@ -69,8 +69,8 @@ - - + + Address-to-name transaltion.

Address-to-name translation in a protocol-independant manner.

@@ -81,10 +81,10 @@
- - - - + + + + Network address and service transation.

Network address and service translation.

@@ -97,7 +97,7 @@
- + Mappings between network interface names and indexes.

Mappings between network interface names and indexes.

@@ -105,7 +105,7 @@
- + Mappings between network interface index and names.

Mappings between network interface index and names.

@@ -113,7 +113,7 @@
- + Get network interface names and indexes.

Get network interface names and indexes.

diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 9e8b9cd29f..795df0d238 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -29,7 +29,7 @@ socket.xml - socket + socket Socket interface.

This module provides an API for the socket interface. @@ -251,8 +251,8 @@ - - + + Accept a connection on a socket.

Accept a connection on a socket.

@@ -264,7 +264,7 @@
- + Bind a name to a socket.

Bind a name to a socket.

@@ -277,7 +277,7 @@
- + Close a socket.

Closes the socket.

@@ -296,8 +296,8 @@
- - + + Initiate a connection on a socket.

This function connects the socket to the address @@ -306,13 +306,13 @@ - - - - - - - + + + + + + + Get an option on a socket.

Get an option on a socket.

@@ -332,7 +332,7 @@
- + Get an option on a socket.

Get an option on a socket.

@@ -354,8 +354,8 @@
- - + + Listen for connections on a socket.

Listen for connections on a socket.

@@ -363,9 +363,9 @@
- - - + + + Create an endpoint for communication.

Creates an endpoint (socket) for communication.

@@ -385,7 +385,7 @@
- + Get name of connected socket peer.

Returns the address of the peer connected to the socket.

@@ -393,11 +393,11 @@
- - - - - + + + + + Receive a message from a socket.

Receive a message from a socket.

@@ -408,12 +408,12 @@
- - - - - - + + + + + + Receive a message from a socket.

Receive a message from a socket.

@@ -432,12 +432,12 @@
- - - - - - + + + + + + Receive a message from a socket.

Receive a message from a socket.

@@ -468,10 +468,10 @@
- - - - + + + + Send a message on a socket.

Send a message on a connected socket.

@@ -479,10 +479,10 @@
- - - - + + + + Send a message on a socket.

Send a message on a socket. The destination, if needed @@ -503,10 +503,10 @@ - - - - + + + + Send a message on a socket.

Send a message on a socket, to the specified destination.

@@ -514,13 +514,13 @@
- - - - - - - + + + + + + + Set options on a socket.

Set options on a socket.

@@ -543,7 +543,7 @@
- + Set options on a socket.

Set options on a socket.

@@ -566,7 +566,7 @@
- + Shut down part of a full-duplex connection.

Shut down all or part of a full-duplex connection.

@@ -574,7 +574,7 @@
- + Get socket name.

Returns the current address to which the socket is bound.

@@ -582,25 +582,25 @@
- - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + Report info about what the platform supports.

This function intends to retreive information about what the -- cgit v1.2.3 From b71c341212fa1ff07eac914e07bc57303c2c4385 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 21 Feb 2019 11:52:50 +0100 Subject: [socket|doc] Improve the examples --- erts/doc/src/socket.xml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/socket.xml b/erts/doc/src/socket.xml index 795df0d238..caf7058b34 100644 --- a/erts/doc/src/socket.xml +++ b/erts/doc/src/socket.xml @@ -614,14 +614,13 @@ Examples -client(Addr, Port) -> +client(Addr, SAddr, SPort) -> {ok, Sock} = socket:open(inet, stream, tcp), - ok = socket:bind(Sock, #{family => inet, - port => 0, - addr => any}), + {ok, _} = socket:bind(Sock, #{family => inet, + addr => Addr}), ok = socket:connect(Sock, #{family => inet, - addr => Addr, - port => Port}), + addr => SAddr, + port => SPort}), Msg = list_to_binary("hello"), ok = socket:send(Sock, Msg), ok = socket:shutdown(Sock, write), @@ -630,9 +629,9 @@ client(Addr, Port) -> server(Addr, Port) -> {ok, LSock} = socket:open(inet, stream, tcp), - ok = socket:bind(LSock, #{family => inet, - port => Port, - addr => Addr}), + {ok, _} = socket:bind(LSock, #{family => inet, + port => Port, + addr => Addr}), ok = socket:listen(LSock), {ok, Sock} = socket:accept(LSock), {ok, Msg} = socket:recv(Sock), -- cgit v1.2.3