10#include <sys/socket.h>
12#include <netinet/in.h>
50 TAddress(
const std::string& addr,
int port);
73 TAddress(sockaddr* addr, socklen_t len);
91 const std::variant<sockaddr_in, sockaddr_in6>&
Addr()
const;
102 std::pair<const sockaddr*, int>
RawAddr()
const;
143 std::variant<sockaddr_in, sockaddr_in6> Addr_ = {};
A class representing an IPv4 or IPv6 address (with port).
Definition address.hpp:38
std::pair< const sockaddr *, int > RawAddr() const
Returns a pointer to the raw sockaddr structure and its size in bytes.
Definition address.cpp:68
int Domain() const
Gets the domain (address family) of the stored address.
Definition address.cpp:45
TAddress()=default
Default constructor. Creates an empty address.
const std::variant< sockaddr_in, sockaddr_in6 > & Addr() const
Retrieves the internal variant storing the address.
Definition address.cpp:67
std::string ToString() const
Converts the address to a human-readable string format.
Definition address.cpp:82
TAddress WithPort(int port) const
Returns a new TAddress with the same IP but a different port.
Definition address.cpp:55
bool operator==(const TAddress &other) const
Equality operator for TAddress.
Definition address.cpp:78