1
%% ``The contents of this file are subject to the Erlang Public License,
4
%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
2
7
%% Version 1.1, (the "License"); you may not use this file except in
3
8
%% compliance with the License. You should have received a copy of the
4
9
%% Erlang Public License along with this software. If not, it can be
5
%% retrieved via the world wide web at http://www.erlang.org/.
10
%% retrieved online at http://www.erlang.org/.
7
12
%% Software distributed under the License is distributed on an "AS IS"
8
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
%% the License for the specific language governing rights and limitations
10
15
%% under the License.
12
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
%% AB. All Rights Reserved.''
100
101
{'active', bool() | 'once'} |
102
103
0 | 1 | 2 | 4 | 'raw' | 'sunrm' | 'asn1' |
103
'cdr' | 'fcgi' | 'line' | 'tpkt' | 'http' | 'httph'} |
104
'cdr' | 'fcgi' | 'line' | 'tpkt' | 'http' | 'httph' | 'http_bin' | 'httph_bin' } |
104
105
{'mode', list() | binary()} |
105
106
{'port', 'port', 'term'} |
106
107
{'exit_on_close', bool()} |
108
109
{'high_watermark', non_neg_integer()} |
109
110
{'bit8', 'clear' | 'set' | 'on' | 'off'} |
110
111
{'send_timeout', non_neg_integer() | 'infinity'} |
112
{'send_timeout_close', bool()} |
111
113
{'delay_send', bool()} |
112
114
{'packet_size', non_neg_integer()} |
113
115
{'read_packets', non_neg_integer()} |
138
140
'add_membership' | 'drop_membership' |
139
141
'header' | 'buffer' | 'active' | 'packet' | 'mode' | 'port' |
140
142
'exit_on_close' | 'low_watermark' | 'high_watermark' | 'bit8' |
141
'send_timeout' | 'delay_send' | 'packet_size' | 'read_packets' |
143
'send_timeout' | 'send_timeout_close' |
144
'delay_send' | 'packet_size' | 'read_packets' |
143
146
{'sctp_status', #sctp_status{}} |
144
147
'sctp_get_peer_addr_info' |
538
541
buffer, header, active, packet, deliver, mode,
539
542
multicast_if, multicast_ttl, multicast_loop,
540
543
exit_on_close, high_watermark, low_watermark,
544
bit8, send_timeout, send_timeout_close
544
547
%% Return a list of statistics options
556
559
[tos, priority, reuseaddr, keepalive, linger, sndbuf, recbuf, nodelay,
557
560
header, active, packet, packet_size, buffer, mode, deliver,
558
561
exit_on_close, high_watermark, low_watermark, bit8, send_timeout,
562
send_timeout_close, delay_send,raw].
561
564
connect_options(Opts, Family) ->
612
615
[tos, priority, reuseaddr, keepalive, linger, sndbuf, recbuf, nodelay,
613
616
header, active, packet, buffer, mode, deliver, backlog,
614
617
exit_on_close, high_watermark, low_watermark, bit8, send_timeout,
615
delay_send, packet_size,raw].
618
send_timeout_close, delay_send, packet_size,raw].
617
620
listen_options(Opts, Family) ->
816
819
Fam =:= inet -> {ok,[IP]};
817
true -> {error,nxdomain}
820
true -> {error,eafnosupport}
819
true -> {error,einval}
822
true -> {error,einval}
821
824
getaddrs_tm({A,B,C,D,E,F,G,H} = IP, Fam, _) ->
822
825
%% Only "syntactic" validation; we assume that the address was
864
867
gethostbyname_tm(Name, Type, Timer, [yp | Opts]) ->
865
gethostbyname_tm(Name, Type, Timer, [native|Opts]);
868
gethostbyname_tm_native(Name, Type, Timer, Opts);
866
869
gethostbyname_tm(Name, Type, Timer, [nis | Opts]) ->
867
gethostbyname_tm(Name, Type, Timer, [native|Opts]);
870
gethostbyname_tm_native(Name, Type, Timer, Opts);
868
871
gethostbyname_tm(Name, Type, Timer, [nisplus | Opts]) ->
869
gethostbyname_tm(Name, Type, Timer, [native|Opts]);
872
gethostbyname_tm_native(Name, Type, Timer, Opts);
870
873
gethostbyname_tm(Name, Type, Timer, [wins | Opts]) ->
871
gethostbyname_tm(Name, Type, Timer, [native|Opts]);
874
gethostbyname_tm_native(Name, Type, Timer, Opts);
872
875
gethostbyname_tm(Name, Type, Timer, [native | Opts]) ->
873
%% Fixme: add (global) timeout to gethost_native
874
case inet_gethost_native:gethostbyname(Name, Type) of
875
{error,formerr} -> {error,einval};
876
{error,timeout} -> {error,timeout};
877
{error,_} -> gethostbyname_tm(Name, Type, Timer, Opts++no_default);
876
gethostbyname_tm_native(Name, Type, Timer, Opts);
877
gethostbyname_tm(_, _, _, [no_default|_]) ->
878
%% If the native resolver has failed, we should not bother
879
%% to try to be smarter and parse the IP address here.
880
881
gethostbyname_tm(Name, Type, Timer, [_ | Opts]) ->
881
882
gethostbyname_tm(Name, Type, Timer, Opts);
883
%% Last resort - parse the hostname as address
882
884
gethostbyname_tm(Name, inet, _Timer, []) ->
883
885
case inet_parse:ipv4_address(Name) of
911
910
%% format ( {0,0,0,0,0,16#ffff,?u16(A,B),?u16(C,D)} ).
912
911
%% This host might not support IPv6.
915
gethostbyname_tm(Name, inet, _, no_default) ->
916
%% If the native resolver has failed, we should not bother
917
%% to try to be smarter and parse the IP address here.
918
case inet_parse:ipv6_address(Name) of
919
{ok,_} -> {error,einval};
920
_ -> {error,nxdomain}
922
gethostbyname_tm(_Name, inet6, _, no_default) ->
923
%% If the native resolver has failed, we should not bother
924
%% to try to be smarter and parse the IP address here.
915
gethostbyname_tm_native(Name, Type, Timer, Opts) ->
916
%% Fixme: add (global) timeout to gethost_native
917
case inet_gethost_native:gethostbyname(Name, Type) of
918
{error,formerr} -> {error,einval};
919
{error,timeout} -> {error,timeout};
920
{error,_} -> gethostbyname_tm(Name, Type, Timer, Opts++[no_default]);
928
927
%% gethostbyaddr with option search
944
943
gethostbyaddr_tm(Addr, Timer, [yp | Opts]) ->
945
gethostbyaddr_tm(Addr, Timer, [native | Opts]);
944
gethostbyaddr_tm_native(Addr, Timer, Opts);
946
945
gethostbyaddr_tm(Addr, Timer, [nis | Opts]) ->
947
gethostbyaddr_tm(Addr, Timer, [native | Opts]);
946
gethostbyaddr_tm_native(Addr, Timer, Opts);
948
947
gethostbyaddr_tm(Addr, Timer, [nisplus | Opts]) ->
949
gethostbyaddr_tm(Addr, Timer, [native | Opts]);
948
gethostbyaddr_tm_native(Addr, Timer, Opts);
950
949
gethostbyaddr_tm(Addr, Timer, [wins | Opts]) ->
951
gethostbyaddr_tm(Addr, Timer, [native | Opts]);
950
gethostbyaddr_tm_native(Addr, Timer, Opts);
952
951
gethostbyaddr_tm(Addr, Timer, [native | Opts]) ->
953
%% Fixme: user timer for timeoutvalue
954
case inet_gethost_native:gethostbyaddr(Addr) of
955
{error,formerr} -> {error, einval};
956
{error,_} -> gethostbyaddr_tm(Addr,Timer,Opts);
952
gethostbyaddr_tm_native(Addr, Timer, Opts);
959
953
gethostbyaddr_tm(Addr, Timer, [_ | Opts]) ->
960
954
gethostbyaddr_tm(Addr, Timer, Opts);
961
955
gethostbyaddr_tm(_Addr, _Timer, []) ->
962
956
{error, nxdomain}.
958
gethostbyaddr_tm_native(Addr, Timer, Opts) ->
959
%% Fixme: user timer for timeoutvalue
960
case inet_gethost_native:gethostbyaddr(Addr) of
961
{error,formerr} -> {error, einval};
962
{error,_} -> gethostbyaddr_tm(Addr,Timer,Opts);
964
966
-spec open(Fd :: integer(),
965
967
Addr :: ip_address(),
966
968
Port :: ip_port(),