:relfileprefix: ../../../ [#boost-urls-url_base-set_port_number] = xref:boost.adoc[pass:[boost]]::xref:boost/urls.adoc[pass:[urls]]::xref:boost/urls/url_base.adoc[pass:[url_base]]::set_port_number Set the port == Synopsis Declared in header `` [source,cpp,subs="verbatim,macros,-callouts"] ---- xref:boost/urls/url_base.adoc[url_base]& set_port_number(xref:std.adoc[std]::uint16_t n); ---- == Description The port is set to the specified integer. === 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->size()`. === Exception Safety Strong guarantee. Calls to allocate may throw. === BNF [,cpp] ---- authority = [ userinfo "@" ] host [ ":" port ] port = *DIGIT ---- === Specification * 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] .