aboutsummaryrefslogtreecommitdiffstats
path: root/test/gun_test.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/gun_test.erl')
-rw-r--r--test/gun_test.erl10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/gun_test.erl b/test/gun_test.erl
index c6cdd8c..84f0a88 100644
--- a/test/gun_test.erl
+++ b/test/gun_test.erl
@@ -44,9 +44,13 @@ init_origin(Transport, Protocol, Fun) ->
Port = receive_from(Pid),
{ok, Pid, Port}.
-init_origin(Parent, tcp, Protocol, Fun) ->
- %% We setup the socket for both IPv4 and IPv6.
- {ok, ListenSocket} = gen_tcp:listen(0, [binary, {active, false}, inet6]),
+init_origin(Parent, Transport, Protocol, Fun)
+ when Transport =:= tcp; Transport =:= tcp6 ->
+ InetOpt = case Transport of
+ tcp -> inet;
+ tcp6 -> inet6
+ end,
+ {ok, ListenSocket} = gen_tcp:listen(0, [binary, {active, false}, InetOpt]),
{ok, {_, Port}} = inet:sockname(ListenSocket),
Parent ! {self(), Port},
{ok, ClientSocket} = gen_tcp:accept(ListenSocket, 5000),