#include <inet6_address.h>
Class that represents an internet (IPv6) address. This inherits from the IP-specific form of a socket address, sockaddr_in.
◆ inet6_address() [1/7]
sockpp::inet6_address::inet6_address |
( |
| ) |
|
|
inline |
Constructs an empty address. The address is initialized to all zeroes.
◆ inet6_address() [2/7]
sockpp::inet6_address::inet6_address |
( |
in_port_t | port | ) |
|
|
inlineexplicit |
Constructs an address for any iface using the specified port. This is a convenient way for a server to specify an address that will bind to all interfaces.
- Parameters
-
port | The port number in native/host byte order. |
◆ inet6_address() [3/7]
sockpp::inet6_address::inet6_address |
( |
const std::string & | saddr, |
|
|
in_port_t | port ) |
|
inline |
Constructs an address using the name of the host and the specified port. This attempts to resolve the host name to an address.
- Parameters
-
saddr | The name of the host. |
port | The port number in native/host byte order. |
◆ inet6_address() [4/7]
sockpp::inet6_address::inet6_address |
( |
const sockaddr_storage & | addr | ) |
|
|
inline |
Constructs the address by copying the specified structure. TODO: Do we actually need a conversion from something that's cast to a sockaddr, but is really a sockaddr_in6?
- Parameters
-
◆ inet6_address() [5/7]
sockpp::inet6_address::inet6_address |
( |
const sock_address & | addr | ) |
|
|
inline |
Constructs the address by copying the specified structure.
- Parameters
-
◆ inet6_address() [6/7]
sockpp::inet6_address::inet6_address |
( |
const sockaddr_in6 & | addr | ) |
|
|
inline |
Constructs the address by copying the specified structure.
- Parameters
-
◆ inet6_address() [7/7]
sockpp::inet6_address::inet6_address |
( |
const inet6_address & | addr | ) |
|
|
inline |
Constructs the address by copying the specified address.
- Parameters
-
◆ address()
in6_addr sockpp::inet6_address::address |
( |
| ) |
const |
|
inline |
Gets 128-bit IPv6 address. The address is usually stored in network byte order.
- Returns
- The IPv6 address.
◆ create() [1/2]
void sockpp::inet6_address::create |
( |
const in6_addr & | addr, |
|
|
in_port_t | port ) |
Creates the socket address using the specified host address and port number.
- Parameters
-
addr | The host address (16-byte IPv6 address). |
port | The host port number. |
◆ create() [2/2]
void sockpp::inet6_address::create |
( |
const std::string & | saddr, |
|
|
in_port_t | port ) |
Creates the socket address using the specified host name and port number.
- Parameters
-
saddr | The string host name. |
port | The port number in native/host byte order. |
◆ is_set()
bool sockpp::inet6_address::is_set |
( |
| ) |
const |
Checks if the address is set to some value. This doesn't attempt to determine if the address is valid, simply that it's not all zero.
- Returns
- bool
◆ loopback()
static inet6_address sockpp::inet6_address::loopback |
( |
in_port_t | port | ) |
|
|
inlinestatic |
Creates an address on the loopback (localhost) interface.
- Parameters
-
port | The port number (in native/host byte order). |
- Returns
- The full address on the loopback interface.
◆ operator[]()
uint8_t sockpp::inet6_address::operator[] |
( |
int | i | ) |
const |
|
inline |
Gets a byte of the 128-bit IPv6 Address.
Note that the address is normally stored in network byte
order.
@param i The byte to read (0-7)
{ return addr_ != sockaddr_in6{};
- Returns
- The specified byte in the 128-bit IPv6 Address
◆ port()
in_port_t sockpp::inet6_address::port |
( |
| ) |
const |
|
inline |
Gets the port number.
- Returns
- The port number in native/host byte order.
◆ resolve_name()
in6_addr sockpp::inet6_address::resolve_name |
( |
const std::string & | saddr | ) |
|
|
static |
Attempts to resolve the host name into a 32-bit internet address.
- Parameters
-
saddr | The string host name. |
- Returns
- The internet address in network byte order.
◆ size()
socklen_t sockpp::inet6_address::size |
( |
| ) |
const |
|
inlineoverridevirtual |
Gets the size of this structure. This is equivalent to sizeof(this) but more convenient in some places.
- Returns
- The size of this structure.
Implements sockpp::sock_address.
◆ sockaddr_in6_ptr() [1/2]
sockaddr_in6 * sockpp::inet6_address::sockaddr_in6_ptr |
( |
| ) |
|
|
inline |
Gets a pointer to this object cast to a sockaddr_in6.
- Returns
- sockaddr_in6 pointer to this object.
◆ sockaddr_in6_ptr() [2/2]
const sockaddr_in6 * sockpp::inet6_address::sockaddr_in6_ptr |
( |
| ) |
const |
|
inline |
Gets a const pointer to this object cast to a sockaddr_in6.
- Returns
- const sockaddr_in6 pointer to this object.
◆ sockaddr_ptr() [1/2]
const sockaddr * sockpp::inet6_address::sockaddr_ptr |
( |
| ) |
const |
|
inlineoverridevirtual |
Gets a pointer to this object cast to a sockaddr.
- Returns
- A pointer to this object cast to a sockaddr.
Implements sockpp::sock_address.
◆ sockaddr_ptr() [2/2]
sockaddr * sockpp::inet6_address::sockaddr_ptr |
( |
| ) |
|
|
inlineoverridevirtual |
Gets a pointer to this object cast to a sockaddr.
- Returns
- A pointer to this object cast to a sockaddr.
Implements sockpp::sock_address.
◆ to_string()
string sockpp::inet6_address::to_string |
( |
| ) |
const |
Gets a printable string for the address. This gets the address in the printable form "[addr]:port" using inet_ntop(). It does not attempt to find the host name using a lookup.
- Returns
- A string representation of the address in the form '[address]:port'
◆ ADDRESS_FAMILY
sa_family_t sockpp::inet6_address::ADDRESS_FAMILY = AF_INET6 |
|
staticconstexpr |
The address family for this type of address
The documentation for this class was generated from the following files: