5 #include "sockaddr_private.h"
17 throw logic_error("no unix sockets on windows");
21 UnixAddr::UnixAddr(const SysAddr &sa):
26 throw logic_error("no unix sockets on windows");
28 const sockaddr_un &sau = reinterpret_cast<const sockaddr_un &>(sa.addr);
29 if(sa.size>sizeof(sa_family_t))
31 abstract = (sau.sun_path[0]==0);
32 path.assign(sau.sun_path+abstract, sa.size-sizeof(sa_family_t)-abstract);
37 UnixAddr::UnixAddr(const string &p, bool a):
42 throw logic_error("no unix sockets on windows");
44 if(sizeof(sa_family_t)+path.size()+1>sizeof(sockaddr_storage))
45 throw invalid_argument("UnixAddr");
49 SockAddr::SysAddr UnixAddr::to_sys() const
53 sa.size = sizeof(sa_family_t);
55 sa.size += path.size()+1;
57 sockaddr_un &sau = reinterpret_cast<sockaddr_un &>(sa.addr);
58 sau.sun_family = AF_UNIX;
63 std::copy(path.begin(), path.end(), sau.sun_path+abstract);
65 sau.sun_path[path.size()] = 0;
72 string UnixAddr::str() const
74 string result = "unix:";