:relfileprefix: ../../../ [#boost-urls-static_url-set_port_number] == xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/static_url.adoc[pass:[static_url]]::set_port_number Set the port === Synopsis Declared in header `` [source,cpp,subs="verbatim,macros,-callouts"] ---- xref:boost/urls/static_url.adoc[static_url]& set_port_number(std::uint16_t n); ---- === Description The port is set to the specified integer. [,cpp] ---- assert( url( "http://www.example.com" ).set_port_number( 8080 ).authority().buffer() == "www.example.com:8080" ); ---- [,cpp] ---- this->has_authority() == true && this->has_port() == true && this->port_number() == n ---- === Linear in `this->size()`. === Strong guarantee. Calls to allocate may throw. [,cpp] ---- authority = [ userinfo "@" ] host [ ":" port ] port = *DIGIT ---- * link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.3[ 3.2.3. Port (rfc3986)] === Parameters |=== | Name | Description | *n* | The port number to set. |=== === See Also xref:boost/urls/url_base/remove_port.adoc[remove_port] , xref:boost/urls/url_base/set_port.adoc[set_port] .