12 #ifndef ROC_ADDRESS_SOCKET_ADDR_H_
13 #define ROC_ADDRESS_SOCKET_ADDR_H_
15 #include <netinet/in.h>
16 #include <sys/socket.h>
71 operator const struct unspecified_bool *()
const;
85 static socklen_t saddr_size_(sa_family_t
family);
87 sa_family_t saddr_family_()
const;
89 bool set_host_port_ipv4_(
const char* ip,
int port);
90 bool set_host_port_ipv6_(
const char* ip,
int port);
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
bool operator==(const SocketAddr &other) const
Compare addresses.
AddrFamily family() const
Get IP version (IPv4 or IPv6).
int port() const
Get address port.
bool operator!=(const SocketAddr &other) const
Compare addresses.
ROC_ATTR_NODISCARD bool set_host_port_auto(const char *host, int port)
Set host address, auto-detect family.
bool has_host_port() const
Check whether host and port are set.
ROC_ATTR_NODISCARD bool set_host_port(AddrFamily type, const char *host, int port)
Set host address.
SocketAddr()
Construct empty address.
socklen_t max_slen() const
Get maximum allowed sockaddr struct length.
socklen_t slen() const
Get sockaddr struct length.
ROC_ATTR_NODISCARD bool set_host_port_saddr(const sockaddr *sa)
Set address from sockaddr struct.
void clear()
Clear address.
ROC_ATTR_NODISCARD bool get_host(char *buf, size_t bufsz) const
Get host IP address.
const sockaddr * saddr() const
Get sockaddr struct.
bool multicast() const
Check whether this is multicast address.
sockaddr * saddr()
Get sockaddr struct.
AddrFamily
Address family.
Commonly used types and functions.