diff options
Diffstat (limited to 'lib/kernel')
-rw-r--r-- | lib/kernel/src/inet.erl | 17 | ||||
-rw-r--r-- | lib/kernel/src/inet_int.hrl | 1 | ||||
-rw-r--r-- | lib/kernel/src/local_tcp.erl | 10 | ||||
-rw-r--r-- | lib/kernel/src/local_udp.erl | 9 |
4 files changed, 28 insertions, 9 deletions
diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl index de43ea792b..a7b3c1cef4 100644 --- a/lib/kernel/src/inet.erl +++ b/lib/kernel/src/inet.erl @@ -1296,7 +1296,7 @@ gethostbyaddr_tm_native(Addr, Timer, Opts) -> end. -spec open(Fd_or_OpenOpts :: integer() | list(), - Addr :: socket_address(), + Addr :: socket_address() | undefined, Port :: port_number(), Opts :: [socket_setopt()], Protocol :: socket_protocol(), @@ -1316,11 +1316,16 @@ open(FdO, Addr, Port, Opts, Protocol, Family, Type, Module) {ok,S} -> case prim_inet:setopts(S, Opts) of ok -> - case if is_list(Addr) -> - bindx(S, Addr, Port); - true -> - prim_inet:bind(S, Addr, Port) - end of + case + case Addr of + undefined -> + {ok, undefined}; + _ when is_list(Addr) -> + bindx(S, Addr, Port); + _ -> + prim_inet:bind(S, Addr, Port) + end + of {ok, _} -> inet_db:register_socket(S, Module), {ok,S}; diff --git a/lib/kernel/src/inet_int.hrl b/lib/kernel/src/inet_int.hrl index 32d09fb63c..c8a8962e78 100644 --- a/lib/kernel/src/inet_int.hrl +++ b/lib/kernel/src/inet_int.hrl @@ -25,6 +25,7 @@ %% %% family codes to open +-define(INET_AF_UNSPEC, 0). -define(INET_AF_INET, 1). -define(INET_AF_INET6, 2). -define(INET_AF_ANY, 3). % Fake for ANY in any address family diff --git a/lib/kernel/src/local_tcp.erl b/lib/kernel/src/local_tcp.erl index 64085ec42e..e3c67dfbb7 100644 --- a/lib/kernel/src/local_tcp.erl +++ b/lib/kernel/src/local_tcp.erl @@ -107,8 +107,14 @@ do_connect(Addr = {?FAMILY, _}, 0, Opts, Time) -> when tuple_size(BAddr) =:= 2, element(1, BAddr) =:= ?FAMILY; BAddr =:= any -> case inet:open( - Fd, BAddr, 0, SockOpts, - ?PROTO, ?FAMILY, ?TYPE, ?MODULE) of + Fd, + case BAddr of + any -> + undefined; + _ -> + BAddr + end, + 0, SockOpts, ?PROTO, ?FAMILY, ?TYPE, ?MODULE) of {ok, S} -> case prim_inet:connect(S, Addr, 0, Time) of ok -> {ok,S}; diff --git a/lib/kernel/src/local_udp.erl b/lib/kernel/src/local_udp.erl index ebb4d2b33f..481a8c4910 100644 --- a/lib/kernel/src/local_udp.erl +++ b/lib/kernel/src/local_udp.erl @@ -59,7 +59,14 @@ open(0, Opts) -> when tuple_size(BAddr) =:= 2, element(1, BAddr) =:= ?FAMILY; BAddr =:= any -> inet:open( - Fd, BAddr, 0, SockOpts, ?PROTO, ?FAMILY, ?TYPE, ?MODULE); + Fd, + case BAddr of + any -> + undefined; + _ -> + BAddr + end, + 0, SockOpts, ?PROTO, ?FAMILY, ?TYPE, ?MODULE); {ok, _} -> exit(badarg) end. |