summaryrefslogtreecommitdiff
path: root/erts/preloaded/src/socket.erl
diff options
context:
space:
mode:
authorDanil Zagoskin <z@gosk.in>2019-10-02 16:06:38 +0300
committerDanil Zagoskin <z@gosk.in>2019-10-02 16:06:38 +0300
commit2b155c61d6f2aabec14705860e957e4ed9e6af25 (patch)
treebe52558ad620aaad953c3c3d01b87f9efedff4a7 /erts/preloaded/src/socket.erl
parentc46f6b36b2f68f1c616406c0e6b1730dcff2b835 (diff)
downloaderlang-2b155c61d6f2aabec14705860e957e4ed9e6af25.tar.gz
socket_nif: improve support for sendmsg ctrl types
fix handling some UNIX socket cmsg_type values from erlang code: * timestamp <-> SCM_TIMESTAMP * rights <-> SCM_RIGHTS * credentials <-> SCM_CREDENTIALS or SCM_CREDS 'rigths' type allows passing file descriptors to another process, which allows passing TCP sockets too, E.g.: ``` % Sender code, FD is an integer file descriptor Ctrl = [#{level => socket, type => rights, data => <<FD:32/native>>}], ok = socket:sendmsg(USock, #{iov => [<<"hello">>], ctrl => Ctrl}), ``` ``` % Receiver side (other process) {ok, Msg} = socket:recvmsg(U), {ctrl := [#{level := socket, type := rights, data := Data}]} = Msg, <<FD:32/native, Rest/binary>> = Data, % On MacOS Rest contains garbage ```
Diffstat (limited to 'erts/preloaded/src/socket.erl')
-rw-r--r--erts/preloaded/src/socket.erl17
1 files changed, 10 insertions, 7 deletions
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index 07e720c44d..fe066e5355 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -615,13 +615,16 @@
#{level := ipv6, type := integer(), data := binary()} |
#{level := integer(), type := integer(), data := binary()}.
-type cmsghdr_send() ::
- #{level := socket, type := integer(), data := binary()} |
- #{level := ip, type := tos, data := ip_tos() | binary()} |
- #{level := ip, type := ttl, data := integer() | binary()} |
- #{level := ip, type := integer(), data := binary()} |
- #{level := ipv6, type := integer(), data := binary()} |
- #{level := udp, type := integer(), data := binary()} |
- #{level := integer(), type := integer(), data := binary()}.
+ #{level := socket, type := timestamp, data := binary()} |
+ #{level := socket, type := rights, data := binary()} |
+ #{level := socket, type := credentials, data := binary()} |
+ #{level := socket, type := integer(), data := binary()} |
+ #{level := ip, type := tos, data := ip_tos() | binary()} |
+ #{level := ip, type := ttl, data := integer() | binary()} |
+ #{level := ip, type := integer(), data := binary()} |
+ #{level := ipv6, type := integer(), data := binary()} |
+ #{level := udp, type := integer(), data := binary()} |
+ #{level := integer(), type := integer(), data := binary()}.
-opaque select_tag() :: atom().