aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--erts/doc/src/socket.xml49
-rw-r--r--erts/preloaded/ebin/socket.beambin67144 -> 68544 bytes
-rw-r--r--erts/preloaded/src/socket.erl83
3 files changed, 129 insertions, 3 deletions
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 @@
<datatype>
<name name="int32"/>
</datatype>
+ <datatype>
+ <name name="supports_options_socket"/>
+ </datatype>
+ <datatype>
+ <name name="supports_options_ip"/>
+ </datatype>
+ <datatype>
+ <name name="supports_options_ipv6"/>
+ </datatype>
+ <datatype>
+ <name name="supports_options_tcp"/>
+ </datatype>
+ <datatype>
+ <name name="supports_options_udp"/>
+ </datatype>
+ <datatype>
+ <name name="supports_options_sctp"/>
+ </datatype>
+ <datatype>
+ <name name="supports_options"/>
+ </datatype>
</datatypes>
<funcs>
@@ -511,6 +532,34 @@
</desc>
</func>
+ <func>
+ <name name="supports" arity="0"/>
+ <name name="supports" arity="1" clause_i="1"/>
+ <name name="supports" arity="1" clause_i="2"/>
+ <name name="supports" arity="1" clause_i="3"/>
+ <name name="supports" arity="1" clause_i="4"/>
+ <name name="supports" arity="2" clause_i="1"/>
+ <name name="supports" arity="2" clause_i="2"/>
+ <name name="supports" arity="2" clause_i="3"/>
+ <name name="supports" arity="2" clause_i="4"/>
+ <name name="supports" arity="2" clause_i="5"/>
+ <name name="supports" arity="2" clause_i="6"/>
+ <name name="supports" arity="2" clause_i="7"/>
+ <name name="supports" arity="3" clause_i="1"/>
+ <name name="supports" arity="3" clause_i="2"/>
+ <name name="supports" arity="3" clause_i="3"/>
+ <name name="supports" arity="3" clause_i="4"/>
+ <name name="supports" arity="3" clause_i="5"/>
+ <name name="supports" arity="3" clause_i="6"/>
+ <name name="supports" arity="3" clause_i="7"/>
+ <fsummary>Report info about what the platform supports.</fsummary>
+ <desc>
+ <p>This function intends to retreive information about what the
+ platform supports. Such as if SCTP is supported. Or which socket
+ options are supported. </p>
+ </desc>
+ </func>
+
</funcs>
<section>
<title>Examples</title>
diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam
index 6b3d488086..a0bf156263 100644
--- a/erts/preloaded/ebin/socket.beam
+++ b/erts/preloaded/ebin/socket.beam
Binary files differ
diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl
index d0e074c817..acf5e18cec 100644
--- a/erts/preloaded/src/socket.erl
+++ b/erts/preloaded/src/socket.erl
@@ -27,7 +27,7 @@
-export([
on_load/0, on_load/1,
info/0,
- supports/0, supports/1,
+ supports/0, supports/1, supports/2, supports/3,
ensure_sockaddr/1
]).
@@ -848,20 +848,97 @@ info() ->
nif_info().
--spec supports() -> list().
+
+%% ===========================================================================
+%%
+%% supports - get information about what the platform "supports".
+%%
+%% Generates a list of various info about what the plaform can support.
+%% The most obvious case is 'options'.
+%%
+%% Each item in a 'supports'-list will appear only *one* time.
+%%
+%% ===========================================================================
+
+-type supports_options_socket() :: [{socket_option(), boolean()}].
+-type supports_options_ip() :: [{ip_socket_option(), boolean()}].
+-type supports_options_ipv6() :: [{ipv6_socket_option(), boolean()}].
+-type supports_options_tcp() :: [{tcp_socket_option(), boolean()}].
+-type supports_options_udp() :: [{udp_socket_option(), boolean()}].
+-type supports_options_sctp() :: [{sctp_socket_option(), boolean()}].
+-type supports_options() :: [{socket, supports_options_socket()} |
+ {ip, supports_options_ip()} |
+ {ipv6, supports_options_ipv6()} |
+ {tcp, supports_options_tcp()} |
+ {udp, supports_options_udp()} |
+ {sctp, supports_options_sctp()}].
+
+-spec supports() -> [{options, supports_options()} |
+ {sctp, boolean()} |
+ {ipv6, boolean()}].
supports() ->
[{options, supports(options)},
{sctp, supports(sctp)},
{ipv6, supports(ipv6)}].
+
+-spec supports(options) -> supports_options();
+ (sctp) -> boolean();
+ (ipv6) -> boolean();
+ (Key1) -> false when
+ Key1 :: term().
+
supports(options) ->
nif_supports(?SOCKET_SUPPORTS_OPTIONS);
supports(sctp) ->
nif_supports(?SOCKET_SUPPORTS_SCTP);
supports(ipv6) ->
nif_supports(?SOCKET_SUPPORTS_IPV6);
-supports(_) ->
+supports(_Key1) ->
+ false.
+
+-spec supports(options, socket) -> supports_options_socket();
+ (options, ip) -> supports_options_ip();
+ (options, ipv6) -> supports_options_ipv6();
+ (options, tcp) -> supports_options_tcp();
+ (options, udp) -> supports_options_udp();
+ (options, sctp) -> supports_options_sctp();
+ (Key1, Key2) -> false when
+ Key1 :: term(),
+ Key2 :: term().
+
+supports(options, Level) ->
+ proplists:get_value(Level, supports(options), false);
+supports(_Key1, _Level) ->
+ false.
+
+
+-spec supports(options, socket, Opt) -> boolean() when
+ Opt :: socket_option();
+ (options, ip, Opt) -> boolean() when
+ Opt :: ip_socket_option();
+ (options, ipv6, Opt) -> boolean() when
+ Opt :: ipv6_socket_option();
+ (options, tcp, Opt) -> boolean() when
+ Opt :: tcp_socket_option();
+ (options, udp, Opt) -> boolean() when
+ Opt :: udp_socket_option();
+ (options, sctp, Opt) -> boolean() when
+ Opt :: sctp_socket_option();
+ (Key1, Key2, Key3) -> false when
+ Key1 :: term(),
+ Key2 :: term(),
+ Key3 :: term().
+
+supports(options, Level, Opt) ->
+ case supports(options, Level) of
+ S when is_list(S) ->
+ proplists:get_value(Opt, S, false);
+ _ ->
+ false
+ end;
+supports(_Key1, _Key2, _Key3) ->
false.