47 #ifndef __sockpp_unix_addr_h 48 #define __sockpp_unix_addr_h 71 static constexpr
size_t SZ =
sizeof(sockaddr_un);
78 static constexpr
size_t MAX_PATH_NAME = 108;
123 bool is_set()
const {
return addr_.sun_path[0] !=
'\0'; }
128 std::string
path()
const {
return std::string(addr_.sun_path); }
137 socklen_t
size()
const override {
return socklen_t(SZ); }
148 return reinterpret_cast<const sockaddr*
>(&addr_);
155 return reinterpret_cast<sockaddr*
>(&addr_);
173 return std::string(
"unix:") + std::string(addr_.sun_path);
191 #endif // __sockpp_unix_addr_h Generic socket address.
Definition: sock_address.h:64
const sockaddr * sockaddr_ptr() const override
Gets a pointer to this object cast to a const sockaddr.
Definition: unix_address.h:147
unix_address(const unix_address &addr)
Constructs the address by copying the specified address.
Definition: unix_address.h:116
unix_address(const sock_address &addr)
Constructs the address by copying the specified structure.
Definition: unix_address.h:101
virtual sockaddr * sockaddr_ptr()=0
Gets a pointer to this object cast to a sockaddr.
bool is_set() const
Checks if the address is set to some value.
Definition: unix_address.h:123
static constexpr sa_family_t ADDRESS_FAMILY
The address family for this type of address.
Definition: unix_address.h:75
std::ostream & operator<<(std::ostream &os, const inet6_address &addr)
Stream inserter for the address.
std::string path() const
Gets the path to which this address refers.
Definition: unix_address.h:128
Class that represents a UNIX domain address.
Definition: unix_address.h:65
const sockaddr_un * sockaddr_un_ptr() const
Gets a const pointer to this object cast to a sockaddr_un.
Definition: unix_address.h:161
std::string to_string() const
Gets a printable string for the address.
Definition: unix_address.h:172
Definition: acceptor.h:51
sockaddr * sockaddr_ptr() override
Gets a pointer to this object cast to a sockaddr.
Definition: unix_address.h:154
socklen_t size() const override
Gets the size of the address structure.
Definition: unix_address.h:137
sockaddr_un * sockaddr_un_ptr()
Gets a pointer to this object cast to a sockaddr_un.
Definition: unix_address.h:166
unix_address()
Constructs an empty address.
Definition: unix_address.h:84
unix_address(const sockaddr_un &addr)
Constructs the address by copying the specified structure.
Definition: unix_address.h:111
Generic address class for sockpp.