[erlang-questions] how can I get the ip address from a socket

Arbow avindev@REDACTED
Thu Nov 23 09:42:15 CET 2006


Deal all:

       I wrote a simple echo_server, want to print incoming
connections ip address.

    case gen_tcp:accept(ListenSocket) of
        {ok, ClientSocket} -> .............

I got the ClientSocket,  and output it :

io:format("Socket ~p connected~n", [ClientSocket]),

The simple output is:
Socket #Port<0.96> connected

Now I want to get the ip address and port of these remote peers, how I
can do ? I can't find any releative functions from module gen_tcp.

Thanks.



More information about the erlang-questions mailing list