diff options
Diffstat (limited to 'lib/kernel/test/gen_tcp_api_SUITE.erl')
-rw-r--r-- | lib/kernel/test/gen_tcp_api_SUITE.erl | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/kernel/test/gen_tcp_api_SUITE.erl b/lib/kernel/test/gen_tcp_api_SUITE.erl index 026cbf8b28..77ec89b4f4 100644 --- a/lib/kernel/test/gen_tcp_api_SUITE.erl +++ b/lib/kernel/test/gen_tcp_api_SUITE.erl @@ -308,9 +308,7 @@ t_implicit_inet6(Host, Addr) -> implicit_inet6(S1, Loopback), ok = gen_tcp:close(S1), %% - Localhost = "localhost", - Localaddr = ok(inet:getaddr(Localhost, inet6)), - io:format("~s ~p~n", [Localhost,Localaddr]), + Localaddr = ok(get_localaddr()), S2 = ok(gen_tcp:listen(0, [{ip,Localaddr}])), implicit_inet6(S2, Localaddr), ok = gen_tcp:close(S2), @@ -593,6 +591,20 @@ ok(NotOk) -> error, {Thrown, NotOk}, tl(erlang:get_stacktrace())) end. +get_localaddr() -> + get_localaddr(["localhost", "localhost6", "ip6-localhost"]). + +get_localaddr([]) -> + {error, localaddr_not_found}; +get_localaddr([Localhost|Ls]) -> + case inet:getaddr(Localhost, inet6) of + {ok, LocalAddr} -> + io:format("~s ~p~n", [Localhost, LocalAddr]), + {ok, LocalAddr}; + _ -> + get_localaddr(Ls) + end. + getsockfd() -> undefined. closesockfd(_FD) -> undefined. |