:relfileprefix: ../../../
[#029F0F05ADAD9DA4BEF6CE290B6FC749BB09D96F]

= Function url::set_port_number

pass:v,q[Set the port]


== Synopsis

Declared in header `</boost/url/url.hpp#L456[boost/url/url.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
xref:boost/urls/url.adoc[url]&
set_port_number(uint16_t n);
----

== Description

pass:v,q[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
pass:v,q[Linear in `this->size()`.]

=== Exception Safety
pass:v,q[Strong guarantee.]
pass:v,q[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)]



== Return Value

* `` 


== Parameters

|===
| Name | Type 

| *n*
| `uint16_t`

|===



