[#boost-urls-static_url-set_port] = xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/static_url.adoc[static_url]::set_port :relfileprefix: ../../../ :mrdocs: Set the port == Synopsis Declared in `<https://www.github.com/boostorg/url/blob/develop/include/boost/url/static_url.hpp#L396[boost/url/static_url.hpp]>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:boost/urls/static_url.adoc[static_url]& set_port(core::string_view s); ---- == Description This port is set to the string, which must contain only digits or be empty. An empty port string is distinct from having no port. == Example [,cpp] ---- assert( url( "http://www.example.com" ).set_port( "8080" ).authority().buffer() == "www.example.com:8080" ); ---- == Postconditions [,cpp] ---- this->has_port() == true && this->port_number() == n && this->port() == std::to_string(n) ---- == Exception Safety Strong guarantee. Calls to allocate may throw. Exceptions thrown on invalid input. == BNF [,cpp] ---- port = *DIGIT ---- == Specification * https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.3[] == Return Value `*this` == Parameters [cols=2] |=== | Name | Description | *s* | The port string to set. |=== == See Also xref:boost/urls/static_url/remove_port.adoc[`remove_port`], xref:boost/urls/static_url/set_port.adoc[`set_port`]. [.small]#Created with https://www.mrdocs.com[MrDocs]#