cowboy_req:sock(3)

NAME

cowboy_req:sock - Socket address and port

DESCRIPTION
    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:

    #{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.
    {IP, Port} = cowboy_req:sock(Req).

SEE ALSO

cowboy_req(3), cowboy_req:peer(3), cowboy_req:cert(3)