[#boost-urls-url_view_base-port]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_view_base.adoc[url&lowbar;view&lowbar;base]::port
:relfileprefix: ../../../
:mrdocs:


Return the port

== Synopsis


Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view_base.hpp#L1512[boost&sol;url&sol;url&lowbar;view&lowbar;base&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
core::string&lowbar;view
port() const noexcept;
----

== Description


If present, this function returns a        string representing the port (which        may be empty)&period;        Otherwise it returns an empty string&period;


=== Example

[,cpp]
----
assert( url_view( "http://localhost.com:8080" ).port() == "8080" );
----

=== Complexity

Constant&period;


=== Exception Safety

Throws nothing&period;


=== BNF

[,cpp]
----
port        = *DIGIT
----

=== Specification

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

Return the port

If present, this function returns a        string representing the port (which        may be empty)&period;        Otherwise it returns an empty string&period;


=== Example

[,cpp]
----
assert( url_view( "http://localhost.com:8080" ).port() == "8080" );
----

=== Complexity

Constant&period;


=== Exception Safety

Throws nothing&period;


=== BNF

[,cpp]
----
port        = *DIGIT
----

=== Specification

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



== See Also


xref:boost/urls/url_view_base/encoded_host_and_port.adoc[encoded&lowbar;host&lowbar;and&lowbar;port],            xref:boost/urls/url_view_base/has_port.adoc[has&lowbar;port],            xref:boost/urls/url_view_base/port_number.adoc[port&lowbar;number]&period;



xref:boost/urls/url_view_base/encoded_host_and_port.adoc[encoded&lowbar;host&lowbar;and&lowbar;port],            xref:boost/urls/url_view_base/has_port.adoc[has&lowbar;port],            xref:boost/urls/url_view_base/port_number.adoc[port&lowbar;number]&period;






[.small]#Created with https://www.mrdocs.com[MrDocs]#
