| 1 |
= ranch:get_addr(3) |
| 2 |
|
| 3 |
== Name |
| 4 |
|
| 5 |
ranch:get_addr - Get the listening address |
| 6 |
|
| 7 |
== Description |
| 8 |
|
| 9 |
[source,erlang] |
| 10 |
---- |
| 11 |
get_addr(Ref :: ranch:ref()) |
| 12 |
-> {IP :: inet:ip_address(), |
| 13 |
Port :: inet:port_number()} |
| 14 |
| {local, SocketFile :: binary()} |
| 15 |
| {undefined, undefined} |
| 16 |
---- |
| 17 |
|
| 18 |
Get the listening address. |
| 19 |
|
| 20 |
== Arguments |
| 21 |
|
| 22 |
Ref:: |
| 23 |
|
| 24 |
The listener name. |
| 25 |
|
| 26 |
== Return value |
| 27 |
|
| 28 |
The address of the listener is returned as a tuple of the form |
| 29 |
`{IP, Port}` when listening on a network interface, or |
| 30 |
`{local, SocketFile}` when listening on a UNIX Domain socket. |
| 31 |
When the listener is suspended, `{undefined, undefined}` will |
| 32 |
be returned. |
| 33 |
|
| 34 |
The IP address is the IP of the network interface the |
| 35 |
socket is bound to. |
| 36 |
|
| 37 |
The socket file is the path of a file on your system the |
| 38 |
socket is bound to. |
| 39 |
|
| 40 |
== Examples |
| 41 |
|
| 42 |
.Get the listening port and IP |
| 43 |
[source,erlang] |
| 44 |
---- |
| 45 |
{IP, Port} = ranch:get_addr(example). |
| 46 |
---- |
| 47 |
|
| 48 |
.Get the listening UNIX Domain socket file |
| 49 |
[source,erlang] |
| 50 |
---- |
| 51 |
{local, SocketFile} = ranch:get_addr(example). |
| 52 |
---- |
| 53 |
|
| 54 |
== See also |
| 55 |
|
| 56 |
link:man:ranch:start_listener(3)[ranch:start_listener(3)], |
| 57 |
link:man:ranch:get_port(3)[ranch:get_port(3)], |
| 58 |
link:man:ranch:info(3)[ranch:info(3)], |
| 59 |
link:man:ranch(3)[ranch(3)] |