boost::urls::authority_view::port_number :: Boost Libraries Documentation

# boost::urls::authority_view::port_number

Return the port

## Synopsis

Declared in `<boost/url/authority_view.hpp>`

    std::uint16_t
    port_number() const noexcept;

## Description

If a port is present and the numerical value is representable, it is returned as an unsigned integer. Otherwise, the number zero is returned.

## Example

    assert( url_view( "http://localhost.com:8080" ).port_number() == 8080 );

## Complexity

Constant.

## Exception Safety

Throws nothing.

## BNF

    port        = *DIGIT

## Specification

- https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.3

## Return Value

The port number

## See Also

`encoded_host_and_port`, `has_port`, `port`.

Created with MrDocs