1 #ifndef SPONGE_LIBSPONGE_ADDRESS_HH
2 #define SPONGE_LIBSPONGE_ADDRESS_HH
7 #include <netinet/in.h>
9 #include <sys/socket.h>
20 operator sockaddr *();
21 operator const sockaddr *()
const;
68 operator const sockaddr *()
const {
return _address; }
Wrapper around sockaddr_storage.
sockaddr_storage storage
The wrapped struct itself.
Wrapper around IPv4 addresses and DNS operations.
std::pair< std::string, uint16_t > ip_port() const
Dotted-quad IP address string ("18.243.0.1") and numeric port.
socklen_t size() const
Size of the underlying address storage.
bool operator==(const Address &other) const
Equality comparison.
Address(const std::string &node, const std::string &service, const addrinfo &hints)
Constructor from ip/host, service/port, and hints to the resolver.
std::string to_string() const
Human-readable string, e.g., "8.8.8.8:53".
uint32_t ipv4_numeric() const
Numeric IP address as an integer (i.e., in host byte order).
static Address from_ipv4_numeric(const uint32_t ip_address)
Create an Address from a 32-bit raw numeric IP address.
socklen_t _size
Size of the wrapped address.
uint16_t port() const
Numeric port (host byte order).
std::string ip() const
Dotted-quad IP address string ("18.243.0.1").
bool operator!=(const Address &other) const
Raw _address
A wrapped sockaddr_storage containing the address.