[#boost-urls-url_view_base-host_ipv4_address]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_view_base.adoc[url&lowbar;view&lowbar;base]::host&lowbar;ipv4&lowbar;address
:relfileprefix: ../../../
:mrdocs:

Return the host IPv4 address

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_view_base.hpp#L1260[boost&sol;url&sol;url&lowbar;view&lowbar;base&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:boost/urls/ipv4_address.adoc[ipv4&lowbar;address]
host&lowbar;ipv4&lowbar;address() const noexcept;
----

== Description

If the host type is xref:boost/urls/host_type.adoc[`host&lowbar;type&colon;&colon;ipv4`], this function returns the address as a value of type xref:boost/urls/ipv4_address.adoc[`ipv4&lowbar;address`]&period; Otherwise, if the host type is not an IPv4 address, it returns a default&hyphen;constructed value which is equal to the unspecified address &quot;0&period;0&period;0&period;0&quot;&period;

== Example

[,cpp]
----
assert( url_view( "http://127.0.0.1/index.htm?user=win95" ).host_ipv4_address() == ipv4_address( "127.0.0.1" ) );
----
== Complexity

Constant&period;

== Exception Safety

Throws nothing&period;

== BNF

[,cpp]
----
IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet

dec-octet   = DIGIT                 ; 0-9
            / %x31-39 DIGIT         ; 10-99
            / "1" 2DIGIT            ; 100-199
            / "2" %x30-34 DIGIT     ; 200-249
            / "25" %x30-35          ; 250-255
----
== Specification

* https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2[3&period;2&period;2&period; Host (rfc3986)]

== Return Value

The IPv4 address as a value of type xref:boost/urls/ipv4_address.adoc[`ipv4&lowbar;address`]&period;


[.small]#Created with https://www.mrdocs.com[MrDocs]#
