address¶
- 功能:提供使用 ipv4 和 ipv6 地址的能力。同时提供了许多实用转换方法。
1 address 成员¶
class address
{
... 省略 ...
private:
// The type of the address.
enum { ipv4, ipv6 } type_;
// The underlying IPv4 address.
asio::ip::address_v4 ipv4_address_;
// The underlying IPv6 address.
asio::ip::address_v6 ipv6_address_;
};
2 address 方法¶
address 类提供了很多方法,比如点分 ip 地址转 address。
class
{
... 省略 ...
/// Get whether the address is an IP version 4 address.
bool is_v4() const ASIO_NOEXCEPT
{
return type_ == ipv4;
}
/// Get whether the address is an IP version 6 address.
bool is_v6() const ASIO_NOEXCEPT
{
return type_ == ipv6;
}
/// Get the address as an IP version 4 address.
ASIO_DECL asio::ip::address_v4 to_v4() const;
/// Get the address as an IP version 6 address.
ASIO_DECL asio::ip::address_v6 to_v6() const;
/// Get the address as a string.
ASIO_DECL std::string to_string() const;
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use other overload.) Get the address as a string.
ASIO_DECL std::string to_string(asio::error_code& ec) const;
/// (Deprecated: Use make_address().) Create an address from an IPv4 address
/// string in dotted decimal form, or from an IPv6 address in hexadecimal
/// notation.
static address from_string(const char* str);
... 省略 ...
}