xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Static Public Attributes | Public Member Functions | Static Public Member Functions | List of all members
xtd::net::ip_address Class Reference

#include <ip_address.h>

Definition

Provides an Internet Protocol (IP) address.

Namespace
xtd::net
Library
xtd.core

Static Public Attributes

static ip_address any
 Provides an IP address that indicates that the server must listen for client activity on all network interfaces. This field is constant. More...
 
static ip_address broadcast
 Provides the IP broadcast address. This field is constant. More...
 
static ip_address ip_v6_any
 The Socket::Bind method uses the cIPv6Any field to indicate that a Socket must listen for client activity on all network interfaces. This field is constant. More...
 
static ip_address ip_v6_loopback
 Provides the IP loopback address. This field is constant. More...
 
static ip_address ip_v6_none
 Provides an IP address that indicates that no network interface should be used. This field is constant. More...
 
static ip_address loopback
 Provides the IP loopback address. This field is constant. More...
 
static ip_address none
 Provides an IP address that indicates that no network interface should be used. This field is constant. More...
 

Public Member Functions

 ip_address ()=default
 Initializes a new instance of the xtd::net::ip_address. More...
 
 ip_address (uint32_t address)
 Initializes a new instance of the xtd::net::ip_address class with the address specified as an int64_t. More...
 
 ip_address (const std::vector< byte_t > &address)
 Initializes a new instance of the xtd::net::ip_address class with the address specified as a byte array. More...
 
 ip_address (const std::vector< byte_t > &address, uint32_t scope_id)
 Initializes a new instance of the xtd::net::ip_address class with the address specified as a byte array. More...
 
 ip_address (byte_t quad_part_address1, byte_t quad_part_address2, byte_t quad_part_address3, byte_t quad_part_address4)
 Initializes a new instance of the xtd::net::ip_address class with the address specified as a four Bytes. More...
 
sockets::address_family address_family () const noexcept
 Gets the address family of the IP address. More...
 
bool equals (const object &other) const noexcept override
 Determines whether the specified object is equal to the current object. More...
 
bool equals (const ip_address &other) const noexcept override
 
std::vector< byte_t > get_address_bytes () const
 Provides a copy of the IPAddress as an array of bytes. More...
 
bool is_ip_v4_mapped_to_ip_v6 () const noexcept
 Gets whether the IP address is an IPv4-mapped IPv6 address. More...
 
bool is_ip_v6_link_local () const noexcept
 Gets whether the address is an IPv6 link local address. More...
 
bool is_ip_v6_multicast () const noexcept
 Gets whether the address is an IPv6 multicast global address. More...
 
bool is_ip_v6_site_local () const noexcept
 Gets whether the address is an IPv6 site local address. More...
 
bool is_ip_v6_teredo () const noexcept
 Gets whether the address is an IPv6 Teredo address. More...
 
ip_address map_to_ip_v4 () const noexcept
 Maps the xtd::net::ip_address object to an IPv4 address. More...
 
ip_address map_to_ip_v6 () const noexcept
 Maps the xtd::net::ip_address object to an IPv6 address. More...
 
uint32_t scope_id () const
 Gets the IPv6 address scope identifier. More...
 
ip_addressscope_id (uint32_t value)
 Sets the IPv6 address scope identifier. More...
 
ustring to_string () const noexcept override
 Converts an Internet address to its standard notation. More...
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 
- Public Member Functions inherited from xtd::iequatable< ip_address >
virtual bool equals (const ip_address &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type. More...
 

Static Public Member Functions

static double host_to_network_order (double host)
 Converts a Double value from host byte order to network byte order. More...
 
static int16_t host_to_network_order (int16_t host)
 Converts a short value from host byte order to network byte order. More...
 
static int32_t host_to_network_order (int32_t host)
 Converts a integer value from host byte order to network byte order. More...
 
static int64_t host_to_network_order (int64_t host)
 Converts a long value from host byte order to network byte order. More...
 
static float host_to_network_order (float host)
 Converts a Single value from host byte order to network byte order. More...
 
static uint16_t host_to_network_order (uint16_t host)
 Converts a short value from host byte order to network byte order. More...
 
static uint32_t host_to_network_order (uint32_t host)
 Converts a integer value from host byte order to network byte order. More...
 
static uint64_t host_to_network_order (uint64_t host)
 Converts a long value from host byte order to network byte order. More...
 
static bool is_loopback (const ip_address &address)
 Indicates whether the specified IP address is the loopback address. More...
 
static double network_to_host_order (double network)
 Converts a Double value from network byte order to host byte order. More...
 
static int16_t network_to_host_order (int16_t network)
 Converts a short value from network byte order to host byte order. More...
 
static int32_t network_to_host_order (int32_t host)
 Converts a integer value from network byte order to host byte order. More...
 
static int64_t network_to_host_order (int64_t network)
 Converts a long value from network byte order to host byte order. More...
 
static float network_to_host_order (float network)
 Converts a Single value from network byte order to host byte order. More...
 
static uint16_t network_to_host_order (uint16_t network)
 Converts a short value from network byte order to host byte order. More...
 
static uint32_t network_to_host_order (uint32_t network)
 Converts a integer value from network byte order to host byte order. More...
 
static uint64 network_to_host_order (uint64 network)
 Converts a long value from network byte order to host byte order. More...
 
static ip_address parse (const ustring &str)
 Converts an IP address string to an xtd::net::ip_address instance. More...
 
static bool try_parse (const ustring &str, ip_address &address)
 Determines whether a string is a valid IP address. More...
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 

Constructor & Destructor Documentation

◆ ip_address() [1/5]

xtd::net::ip_address::ip_address ( )
default

Initializes a new instance of the xtd::net::ip_address.

Remarks
ip_address is initialized by default value xtd::net::ip_address::none.

◆ ip_address() [2/5]

xtd::net::ip_address::ip_address ( uint32_t  address)
explicit

Initializes a new instance of the xtd::net::ip_address class with the address specified as an int64_t.

Parameters
addressThe value of the IP address. For example, the value 0x2414188F in big-endian format would be the IP address "143.24.20.36".

◆ ip_address() [3/5]

xtd::net::ip_address::ip_address ( const std::vector< byte_t > &  address)
explicit

Initializes a new instance of the xtd::net::ip_address class with the address specified as a byte array.

Parameters
addressThe byte array value of the IP address.

◆ ip_address() [4/5]

xtd::net::ip_address::ip_address ( const std::vector< byte_t > &  address,
uint32_t  scope_id 
)

Initializes a new instance of the xtd::net::ip_address class with the address specified as a byte array.

Parameters
addressThe byte array value of the IP address.
scope_idThe long value of the scope identifier.
Exceptions
xtd::argument_out_of_range_exceptionscope_id < 0 or scope_id > 0x00000000FFFFFFFF.
Remarks
This constructor instantiates an IPv6 address. The scope_dd identifies a network interface in the case of a link-local address.
The scope is valid only for link-local and site-local addresses.
The byte array is assumed to be in network byte order with the most significant byte first in index position 0.

◆ ip_address() [5/5]

xtd::net::ip_address::ip_address ( byte_t  quad_part_address1,
byte_t  quad_part_address2,
byte_t  quad_part_address3,
byte_t  quad_part_address4 
)

Initializes a new instance of the xtd::net::ip_address class with the address specified as a four Bytes.

Parameters
quad_part_address1The first quad part of the IP address.
quad_part_address2The second quad part of the IP address.
quad_part_address3The third quad part of the IP address.
quad_part_address4The fourth quad part of the IP address.

Member Function Documentation

◆ address_family()

sockets::address_family xtd::net::ip_address::address_family ( ) const
noexcept

Gets the address family of the IP address.

Returns
Returns sockets::address_family::inter_network for IPv4 or sockets::address_family::inter_network_v6 for IPv6.

◆ equals()

bool xtd::net::ip_address::equals ( const object obj) const
overridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.
Examples
The following code example compares the current instance with another object.

Reimplemented from xtd::object.

◆ get_address_bytes()

std::vector<byte_t> xtd::net::ip_address::get_address_bytes ( ) const

Provides a copy of the IPAddress as an array of bytes.

Returns
A byte array.

◆ host_to_network_order() [1/8]

static double xtd::net::ip_address::host_to_network_order ( double  host)
static

Converts a Double value from host byte order to network byte order.

Parameters
hostThe number to convert, expressed in host byte order.
Returns
A Double value, expressed in network byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values.Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::host_to_network_order method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

◆ host_to_network_order() [2/8]

static int16_t xtd::net::ip_address::host_to_network_order ( int16_t  host)
static

Converts a short value from host byte order to network byte order.

Parameters
hostThe number to convert, expressed in host byte order.
Returns
A short value, expressed in network byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values.Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::host_to_network_order method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

◆ host_to_network_order() [3/8]

static int32_t xtd::net::ip_address::host_to_network_order ( int32_t  host)
static

Converts a integer value from host byte order to network byte order.

Parameters
hostThe number to convert, expressed in host byte order.
Returns
A integer value, expressed in network byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values.Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::host_to_network_order method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

◆ host_to_network_order() [4/8]

static int64_t xtd::net::ip_address::host_to_network_order ( int64_t  host)
static

Converts a long value from host byte order to network byte order.

Parameters
hostThe number to convert, expressed in host byte order.
Returns
A long value, expressed in network byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values.Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::host_to_network_order method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

◆ host_to_network_order() [5/8]

static float xtd::net::ip_address::host_to_network_order ( float  host)
static

Converts a Single value from host byte order to network byte order.

Parameters
hostThe number to convert, expressed in host byte order.
Returns
A Single value, expressed in network byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values.Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::host_to_network_order method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

◆ host_to_network_order() [6/8]

static uint16_t xtd::net::ip_address::host_to_network_order ( uint16_t  host)
static

Converts a short value from host byte order to network byte order.

Parameters
hostThe number to convert, expressed in host byte order.
Returns
A unsigned short value, expressed in network byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values.Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::host_to_network_order method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

◆ host_to_network_order() [7/8]

static uint32_t xtd::net::ip_address::host_to_network_order ( uint32_t  host)
static

Converts a integer value from host byte order to network byte order.

Parameters
hostThe number to convert, expressed in host byte order.
Returns
A unsigned integer value, expressed in network byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values.Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::host_to_network_order method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

◆ host_to_network_order() [8/8]

static uint64_t xtd::net::ip_address::host_to_network_order ( uint64_t  host)
static

Converts a long value from host byte order to network byte order.

Parameters
hostThe number to convert, expressed in host byte order.
Returns
A unsigned long value, expressed in network byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values.Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::host_to_network_order method converts multibyte integer values that are stored on the host system from the byte order used by the host to the byte order used by the network.

◆ is_ip_v4_mapped_to_ip_v6()

bool xtd::net::ip_address::is_ip_v4_mapped_to_ip_v6 ( ) const
noexcept

Gets whether the IP address is an IPv4-mapped IPv6 address.

Returns
true if the IP address is an IPv4-mapped IPv6 address; otherwise, false.
Remarks
Dual-stack sockets always require IPv6 addresses. The ability to interact with an IPv4 address requires the use of the IPv4-mapped IPv6 address format. Any IPv4 addresses must be represented in the IPv4-mapped IPv6 address format which enables an IPv6 only application to communicate with an IPv4 node. The IPv4-mapped IPv6 address format allows the IPv4 address of an IPv4 node to be represented as an IPv6 address. The IPv4 address is encoded into the low-order 32 bits of the IPv6 address, and the high-order 96 bits hold the fixed prefix 0:0:0:0:0:FFFF. The IPv4-mapped IPv6 address format is specified in RFC 4291. For more information, see www.ietf.org/rfc/rfc4291.txt.

◆ is_ip_v6_link_local()

bool xtd::net::ip_address::is_ip_v6_link_local ( ) const
noexcept

Gets whether the address is an IPv6 link local address.

Returns
bool true if the IP address is an IPv6 link local address; otherwise, false.

◆ is_ip_v6_multicast()

bool xtd::net::ip_address::is_ip_v6_multicast ( ) const
noexcept

Gets whether the address is an IPv6 multicast global address.

Returns
bool true if the IP address is an IPv6 multicast global address; otherwise, false.

◆ is_ip_v6_site_local()

bool xtd::net::ip_address::is_ip_v6_site_local ( ) const
noexcept

Gets whether the address is an IPv6 site local address.

Returns
bool true if the IP address is an IPv6 site local address; otherwise, false.

◆ is_ip_v6_teredo()

bool xtd::net::ip_address::is_ip_v6_teredo ( ) const
noexcept

Gets whether the address is an IPv6 Teredo address.

Returns
true if the IP address is an IPv6 Teredo address; otherwise, false.
Remarks
A Teredo address is an IPv6 address with the prefix of 2001::/32. Teredo addresses can be returned through normal DNS name resolution or enumerated as an IPv6 address assigned to a local interface.

◆ is_loopback()

static bool xtd::net::ip_address::is_loopback ( const ip_address address)
static

Indicates whether the specified IP address is the loopback address.

Parameters
addressAn IP address.
Returns
bool true if address is the loopback address; otherwise, false.

◆ map_to_ip_v4()

ip_address xtd::net::ip_address::map_to_ip_v4 ( ) const
noexcept

Maps the xtd::net::ip_address object to an IPv4 address.

Returns
An IPv4 address.
Remarks
Dual-stack sockets always require IPv6 addresses. The ability to interact with an IPv4 address requires the use of the IPv4-mapped IPv6 address format. Any IPv4 addresses must be represented in the IPv4-mapped IPv6 address format which enables an IPv6 only application to communicate with an IPv4 node. The IPv4-mapped IPv6 address format allows the IPv4 address of an IPv4 node to be represented as an IPv6 address. The IPv4 address is encoded into the low-order 32 bits of the IPv6 address, and the high-order 96 bits hold the fixed prefix 0:0:0:0:0:FFFF. The IPv4-mapped IPv6 address format is specified in RFC 4291. For more information, see www.ietf.org/rfc/rfc4291.txt.

◆ map_to_ip_v6()

ip_address xtd::net::ip_address::map_to_ip_v6 ( ) const
noexcept

Maps the xtd::net::ip_address object to an IPv6 address.

Returns
An IPv6 address.
Remarks
Dual-stack sockets always require IPv6 addresses. The ability to interact with an IPv4 address requires the use of the IPv4-mapped IPv6 address format. Any IPv4 addresses must be represented in the IPv4-mapped IPv6 address format which enables an IPv6 only application to communicate with an IPv4 node. The IPv4-mapped IPv6 address format allows the IPv4 address of an IPv4 node to be represented as an IPv6 address. The IPv4 address is encoded into the low-order 32 bits of the IPv6 address, and the high-order 96 bits hold the fixed prefix 0:0:0:0:0:FFFF. The IPv4-mapped IPv6 address format is specified in RFC 4291. For more information, see www.ietf.org/rfc/rfc4291.txt.

◆ network_to_host_order() [1/8]

static double xtd::net::ip_address::network_to_host_order ( double  network)
static

Converts a Double value from network byte order to host byte order.

Parameters
networkThe number to convert, expressed in network byte order.
Returns
A Double value, expressed in host byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::network_to_host_order method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

◆ network_to_host_order() [2/8]

static int16_t xtd::net::ip_address::network_to_host_order ( int16_t  network)
static

Converts a short value from network byte order to host byte order.

Parameters
networkThe number to convert, expressed in network byte order.
Returns
A short value, expressed in host byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::network_to_host_order method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

◆ network_to_host_order() [3/8]

static int32_t xtd::net::ip_address::network_to_host_order ( int32_t  host)
static

Converts a integer value from network byte order to host byte order.

Parameters
hostThe number to convert, expressed in network byte order.
Returns
A integer value, expressed in host byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::network_to_host_order method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

◆ network_to_host_order() [4/8]

static int64_t xtd::net::ip_address::network_to_host_order ( int64_t  network)
static

Converts a long value from network byte order to host byte order.

Parameters
networkThe number to convert, expressed in network byte order.
Returns
A long value, expressed in host byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::network_to_host_order method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

◆ network_to_host_order() [5/8]

static float xtd::net::ip_address::network_to_host_order ( float  network)
static

Converts a Single value from network byte order to host byte order.

Parameters
networkThe number to convert, expressed in host byte order.
Returns
A Single value, expressed in host byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::network_to_host_order method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

◆ network_to_host_order() [6/8]

static uint16_t xtd::net::ip_address::network_to_host_order ( uint16_t  network)
static

Converts a short value from network byte order to host byte order.

Parameters
networkThe number to convert, expressed in network byte order.
Returns
A unsigned short value, expressed in host byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::network_to_host_order method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

◆ network_to_host_order() [7/8]

static uint32_t xtd::net::ip_address::network_to_host_order ( uint32_t  network)
static

Converts a integer value from network byte order to host byte order.

Parameters
networkThe number to convert, expressed in network byte order.
Returns
A unsigned integer value, expressed in host byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::network_to_host_order method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

◆ network_to_host_order() [8/8]

static uint64 xtd::net::ip_address::network_to_host_order ( uint64  network)
static

Converts a long value from network byte order to host byte order.

Parameters
networkThe number to convert, expressed in network byte order.
Returns
A unsigned long value, expressed in host byte order.
Remarks
Different computers use different conventions for ordering the bytes within multibyte integer values. Some computers put the most significant byte first (known as big-endian order) and others put the least-significant byte first (known as little-endian order). To work with computers that use different byte ordering, all integer values that are sent over the network are sent in network byte order which has the most significant byte first.
The xtd::net::sockets::socket::network_to_host_order method converts multibyte integer values that are stored on the host system from the byte order used by the network to the byte order used by the host.

◆ parse()

static ip_address xtd::net::ip_address::parse ( const ustring str)
static

Converts an IP address string to an xtd::net::ip_address instance.

Parameters
strA string that contains an IP address in dotted-quad notation for IPv4 and in colon-hexadecimal notation for IPv6.
Returns
An xtd::net::ip_address instance.
Exceptions
xtd::format_exceptionstr is not a valid IP address.
Remarks
The static xtd::net::ip_address::parse method creates an xtd::net::ip_address instance from an IP address expressed in dotted-quad notation for IPv4 and in colon-hexadecimal notation for IPv6.
The number of parts (each part is separated by a period) in str determines how the IP address is constructed. A one part address is stored directly in the network address. A two part address, convenient for specifying a class A address, puts the leading part in the first byte and the trailing part in the right-most three bytes of the network address. A three part address, convenient for specifying a class B address, puts the first part in the first byte, the second part in the second byte, and the final part in the right-most two bytes of the network address.

◆ scope_id() [1/2]

uint32_t xtd::net::ip_address::scope_id ( ) const

Gets the IPv6 address scope identifier.

Returns
A uint32_t that specifies the scope of the address.
Exceptions
xtd::net::sockets::socket_exceptionif address_family = sockets::address_family::inter_network

◆ scope_id() [2/2]

ip_address& xtd::net::ip_address::scope_id ( uint32_t  value)

Sets the IPv6 address scope identifier.

Parameters
valueA uint32_t that specifies the scope of the address.
Exceptions
xtd::net::sockets::socket_exceptionif address_family = sockets::address_family::inter_network

◆ to_string()

ustring xtd::net::ip_address::to_string ( ) const
overridevirtualnoexcept

Converts an Internet address to its standard notation.

Returns
A string that contains the IP address in either IPv4 dotted-quad or in IPv6 colon-hexadecimal notation.

Reimplemented from xtd::object.

◆ try_parse()

static bool xtd::net::ip_address::try_parse ( const ustring str,
ip_address address 
)
static

Determines whether a string is a valid IP address.

Parameters
strThe string to validate.
addressThe xtd::net::ip_address version of the string.
Returns
bool true if str is a valid IP address; otherwise, false.

Member Data Documentation

◆ any

ip_address xtd::net::ip_address::any
static

Provides an IP address that indicates that the server must listen for client activity on all network interfaces. This field is constant.

Remarks
The td::net::ip_address::any field is equivalent to 0.0.0.0 in dotted-quad notation

◆ broadcast

ip_address xtd::net::ip_address::broadcast
static

Provides the IP broadcast address. This field is constant.

Remarks
The td::net::ip_address::broadcast field is equivalent to 255.255.255.255 in dotted-quad notation.

◆ ip_v6_any

ip_address xtd::net::ip_address::ip_v6_any
static

The Socket::Bind method uses the cIPv6Any field to indicate that a Socket must listen for client activity on all network interfaces. This field is constant.

Remarks
The td::net::ip_address::ip_v6_any field is equivalent to 0:0:0:0:0:0:0:0 in colon-hexadecimal notation, or to :: in compact notation.

◆ ip_v6_loopback

ip_address xtd::net::ip_address::ip_v6_loopback
static

Provides the IP loopback address. This field is constant.

Remarks
The td::net::ip_address::ip_v6_loopback field is equivalent to 0:0:0:0:0:0:0:1 in colon-hexadecimal notation, or to ::1 in compact notation.

◆ ip_v6_none

ip_address xtd::net::ip_address::ip_v6_none
static

Provides an IP address that indicates that no network interface should be used. This field is constant.

Remarks
The Socket::Bind method uses the cIPv6None field to indicate that a Socket must not listen for client activity.
The td::net::ip_address::ip_v6_none field is equivalent to 0:0:0:0:0:0:0:0 in colon-hexadecimal notation, or to ::0 in compact notation.

◆ loopback

ip_address xtd::net::ip_address::loopback
static

Provides the IP loopback address. This field is constant.

Remarks
The td::net::ip_address::loopback field is equivalent to 127.0.0.1 in dotted-quad notation.

◆ none

ip_address xtd::net::ip_address::none
static

Provides an IP address that indicates that no network interface should be used. This field is constant.

Remarks
The td::net::ip_address::none field is equivalent to 255.255.255.255 in dotted-quad notation.

The documentation for this class was generated from the following file: