blob: 92428c9f101ce660ce6617854f4e8b44aa163681 (
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
|
= cowboy_req:sock(3)
== Name
cowboy_req:sock - Socket address and port
== Description
[source,erlang]
----
sock(Req :: cowboy_req:req()) -> Info
Info :: {inet:ip_address(), inet:port_number()}
----
Return the socket's IP address and port number.
The socket information can also be obtained using pattern matching:
[source,erlang]
----
#{sock := {IP, Port}} = Req.
----
== Arguments
Req::
The Req object.
== Return value
The socket's local IP address and port number.
== Changelog
* *2.1*: Function introduced.
== Examples
.Get the socket's IP address and port number.
[source,erlang]
----
{IP, Port} = cowboy_req:sock(Req).
----
== See also
link:man:cowboy_req(3)[cowboy_req(3)],
link:man:cowboy_req:peer(3)[cowboy_req:peer(3)],
link:man:cowboy_req:cert(3)[cowboy_req:cert(3)]
|