ranch:get_addr(3)

NAME

ranch:get_addr - Get the listening address

DESCRIPTION
    get_addr(Ref :: ranch:ref())
        -> {IP   :: inet:ip_address(),
            Port :: inet:port_number()}
         | {local, SocketFile :: binary()}
         | {undefined, undefined}

Get the listening address.

ARGUMENTS

Ref
    The listener name.

RETURN VALUE

The address of the listener is returned as a tuple of the form {IP, Port} when listening on a network interface, or {local, SocketFile} when listening on a UNIX Domain socket. When the listener is suspended, {undefined, undefined} will be returned.

The IP address is the IP of the network interface the socket is bound to.

The socket file is the path of a file on your system the socket is bound to.

EXAMPLES

Get the listening port and IP
    {IP, Port} = ranch:get_addr(example).

Get the listening UNIX Domain socket file
    {local, SocketFile} = ranch:get_addr(example).

SEE ALSO

ranch:start_listener(3), ranch:get_port(3), ranch:info(3), ranch(3)