ranch:get_port(3)

Name

ranch:get_port - Get the listening port

Description

get_port(Ref :: ranch:ref())
    -> Port :: inet:port_number() | undefined

Get the listening port.

This function is particularly useful to retrieve the listening port number when it was not provided in the options and was chosen randomly instead.

Arguments

Ref

The listener name.

Return value

The listening port is returned.

When the listener is suspended or using a UNIX Domain socket instead of a network interface, undefined will be returned.

Examples

Get the listening port
Port = ranch:get_port(example).

See also

ranch:start_listener(3), ranch:get_addr(3), ranch:info(3), ranch(3)

Ranch 2.3 Function Reference

Navigation

Version select

Sponsor me!

Support my work on Cowboy, Ranch, Gun and Erlang.mk via GitHub Sponsors. The funds cover domain names and development tools.