:relfileprefix: ../../../
[#boost-urls-url_view_base-port_number]

== xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/url_view_base.adoc[pass:[url_view_base]]::port_number


Return the port


=== Synopsis

Declared in header `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view_base.hpp#L1576[boost/url/url_view_base.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
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.
[,cpp]
----
assert( url_view( "http://localhost.com:8080" ).port_number() == 8080 );
----

=== Constant.

=== Throws nothing.
[,cpp]
----
port        = *DIGIT
----

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.3[3.2.3. Port (rfc3986)]








=== See Also


xref:boost/urls/url_view_base/encoded_host_and_port.adoc[encoded_host_and_port]
,
xref:boost/urls/url_view_base/has_port.adoc[has_port]
,
xref:boost/urls/url_view_base/port.adoc[port]
.



