aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded/src/socket.erl
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-05-08 11:47:43 +0200
committerMicael Karlberg <[email protected]>2018-09-18 13:01:37 +0200
commitf7f70b94f90b1f500cb884be8ae722e1a22acf2e (patch)
treec46bea5f0ff1dbd743456e6c94bb81ba5b64a287 /erts/preloaded/src/socket.erl
parent0ab2ce1aad7596e81c1c59f71ccb3b2ad4f7f070 (diff)
downloadotp-f7f70b94f90b1f500cb884be8ae722e1a22acf2e.tar.gz
otp-f7f70b94f90b1f500cb884be8ae722e1a22acf2e.tar.bz2
otp-f7f70b94f90b1f500cb884be8ae722e1a22acf2e.zip
[socket-nif] setopt of (tcp) congestion
Diffstat (limited to 'erts/preloaded/src/socket.erl')
-rw-r--r--erts/preloaded/src/socket.erl28
1 files changed, 23 insertions, 5 deletions
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index 5bea039783..1304e79c99 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -267,8 +267,7 @@
-type tcp_socket_option() :: congestion |
maxseg |
- nodelay |
- user_timeout.
+ nodelay.
-type udp_socket_option() :: checksum |
maxdgram |
@@ -440,7 +439,8 @@
-define(SOCKET_OPT_IPV6_HOPLIMIT, 0).
--define(SOCKET_OPT_TCP_MAXSEG, 0).
+-define(SOCKET_OPT_TCP_CONGESTION, 0).
+-define(SOCKET_OPT_TCP_MAXSEG, 1).
-define(SOCKET_SHUTDOWN_HOW_READ, 0).
-define(SOCKET_SHUTDOWN_HOW_WRITE, 1).
@@ -1633,11 +1633,21 @@ enc_setopt_value(ipv6, hoplimit, V, _D, T, _P)
enc_setopt_value(ipv6 = L, Opt, V, _D, _T, _P) ->
not_supported({L, Opt, V});
+enc_setopt_value(tcp, congetsion, V, _D, T, P)
+ when is_list(V) andalso
+ (T =:= stream) andalso
+ (P =:= tcp) ->
+ V;
enc_setopt_value(tcp, maxseg, V, _D, T, P)
when is_integer(V) andalso
(T =:= stream) andalso
(P =:= tcp) ->
V;
+enc_setopt_value(tcp, nodelay, V, _D, T, P)
+ when is_boolean(V) andalso
+ (T =:= stream) andalso
+ (P =:= tcp) ->
+ V;
enc_setopt_value(tcp = L, Opt, V, _D, _T, _P) ->
not_supported({L, Opt, V});
@@ -1880,8 +1890,8 @@ enc_sockopt_key(ip, recvttl = Opt, _Dir, _D, T, _P) when (T =/= stream) ->
not_supported(Opt);
enc_sockopt_key(ip, retopts = Opt, _Dir, _D, _T, _P) ->
not_supported(Opt);
-enc_sockopt_key(ip, router_alert = Opt, _Dir, _D, raw = _T, _P) ->
- not_supported(Opt);
+enc_sockopt_key(ip, router_alert = _Opt, _Dir, _D, raw = _T, _P) ->
+ ?SOCKET_OPT_IP_ROUTER_ALERT;
%% On FreeBSD it specifies that this option is only valid
%% for stream, dgram and "some" raw sockets...
%% No such condition on linux (in the man page)...
@@ -1904,6 +1914,14 @@ enc_sockopt_key(ipv6, UnknownOpt, _Dir, _D, _T, _P) ->
unknown(UnknownOpt);
%% TCP socket options
+%% There are other options that would be useful; info,
+%% but they are difficult to get portable...
+enc_sockopt_key(tcp, congestion = _Opt, _Dir, _D, _T, _P) ->
+ ?SOCKET_OPT_TCP_CONGESTION;
+enc_sockopt_key(tcp, maxseg = _Opt, _Dir, _D, _T, _P) ->
+ ?SOCKET_OPT_TCP_MAXSEG;
+enc_sockopt_key(tcp, nodelay = Opt, _Dir, _D, _T, _P) ->
+ not_supported(Opt);
enc_sockopt_key(tcp, UnknownOpt, _Dir, _D, _T, _P) ->
unknown(UnknownOpt);