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)

Cowboy 2.2 Function Reference

Navigation

Version select

Like my work? Donate!

Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:

Recurring payment options are also available via BountySource. These funds are used to cover the recurring expenses like dedicated servers or domain names.