|
Sponge
CS144's user-space TCP library
|
Go to the documentation of this file. 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; }
85 #endif // SPONGE_LIBSPONGE_ADDRESS_HH
bool operator!=(const Address &other) const
Wrapper around sockaddr_storage.
static Address from_ipv4_numeric(const uint32_t ip_address)
Create an Address from a 32-bit raw numeric IP address.
Wrapper around IPv4 addresses and DNS operations.
uint32_t ipv4_numeric() const
Numeric IP address as an integer (i.e., in host byte order).
socklen_t _size
Size of the wrapped address.
Raw _address
A wrapped sockaddr_storage containing the address.
sockaddr_storage storage
The wrapped struct itself.
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.
socklen_t size() const
Size of the underlying address storage.
uint16_t port() const
Numeric port (host byte order).
std::string to_string() const
Human-readable string, e.g., "8.8.8.8:53".
std::string ip() const
Dotted-quad IP address string ("18.243.0.1").
std::pair< std::string, uint16_t > ip_port() const
Dotted-quad IP address string ("18.243.0.1") and numeric port.