[#boost-urls-static_url-set_port_number]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/static_url.adoc[static&lowbar;url]::set&lowbar;port&lowbar;number
:relfileprefix: ../../../
:mrdocs:


Set the port

== Synopsis


Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/static_url.hpp#L392[boost&sol;url&sol;static&lowbar;url&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/static_url.adoc[static&lowbar;url]&
set&lowbar;port&lowbar;number(std::uint16&lowbar;t n);
----

== Description


The port is set to the specified integer&period;


=== Example

[,cpp]
----
assert( url( "http://www.example.com" ).set_port_number( 8080 ).authority().buffer() == "www.example.com:8080" );
----

=== Postconditions

[,cpp]
----
this->has_authority() == true && this->has_port() == true && this->port_number() == n
----

=== Complexity

Linear in `this&hyphen;&gt;size()`&period;


=== Exception Safety

Strong guarantee&period;        Calls to allocate may throw&period;


=== BNF

[,cpp]
----
authority     = [ userinfo "@" ] host [ ":" port ]

port          = *DIGIT
----

=== Specification

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



== Parameters


|===
| Name | Description

| *n*
| The port number to set&period;


|===

== See Also


xref:boost/urls/url_base/remove_port.adoc[remove&lowbar;port],            xref:boost/urls/url_base/set_port.adoc[set&lowbar;port]&period;






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