aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/manual/ranch.get_addr.asciidoc
blob: 7c48b3c7b356ffe78d7b20cef7efc93369fedb47 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
= ranch:get_addr(3)

== Name

ranch:get_addr - Get the listening address

== Description

[source,erlang]
----
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
[source,erlang]
----
{IP, Port} = ranch:get_addr(example).
----

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

== See also

link:man:ranch:start_listener(3)[ranch:start_listener(3)],
link:man:ranch:get_port(3)[ranch:get_port(3)],
link:man:ranch:info(3)[ranch:info(3)],
link:man:ranch(3)[ranch(3)]