[#boost-urls-url_base-set_port_number] = xref:boost/urls/url_base/set_port_number.adoc[boost::urls::url_base::set_port_number] :relfileprefix: ../../../ :mrdocs: Set the port == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_base.hpp#L1556[boost/url/url_base.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:boost/urls/url_base.adoc[url_base]& set_port_number(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 * https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.3[] == Return Value `*this` == Parameters [cols=2] |=== | 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`]. [.small]#Created with https://www.mrdocs.com[MrDocs]#