Pretty print accepted transport address

This commit is contained in:
Evgeniy Khramtsov 2014-04-09 13:12:20 +04:00 committed by Christophe Romain
parent 66006ba017
commit a21edc2f3a
1 changed files with 4 additions and 3 deletions

View File

@ -285,9 +285,10 @@ accept(ListenSocket, Module, Opts) ->
case gen_tcp:accept(ListenSocket) of
{ok, Socket} ->
case {inet:sockname(Socket), inet:peername(Socket)} of
{{ok, Addr}, {ok, PAddr}} ->
?INFO_MSG("(~w) Accepted connection ~w -> ~w",
[Socket, PAddr, Addr]);
{{ok, {Addr, Port}}, {ok, {PAddr, PPort}}} ->
?INFO_MSG("(~w) Accepted connection ~s:~p -> ~s:~p",
[Socket, inet_parse:ntoa(PAddr), PPort,
inet_parse:ntoa(Addr), Port]);
_ ->
ok
end,