17 #ifndef __COMMON_DOMAIN_SOCKETS_HPP__ 18 #define __COMMON_DOMAIN_SOCKETS_HPP__ 40 const std::string&
path,
41 int mode = DOMAIN_SOCKET_DEFAULT_MODE)
53 LOG(INFO) <<
"Removing existing socket at " << path;
54 ::unlink(path.c_str());
60 if (socket.isError()) {
62 "Failed to create unix domain socket: " + socket.error());
70 "Failed to parse path " + path +
": " + addr.error());
74 if (bound.isError()) {
76 "Failed to bind domain socket to path " + path +
": " +
81 if (chmod.isError()) {
82 return Error(
"Couldn't change domain socket permissions: " +
93 #endif // __COMMON_DOMAIN_SOCKETS_HPP__
Definition: errorbase.hpp:36
bool issocket(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:117
Try< Nothing > chmod(const std::string &path, int mode)
Definition: os.hpp:195
constexpr size_t DOMAIN_SOCKET_MAX_PATH_LENGTH
Definition: domain_sockets.hpp:35
static Try< Socket > create(int_fd s, SocketImpl::Kind kind=SocketImpl::DEFAULT_KIND())
Returns an instance of a Socket using the specified kind of implementation.
Definition: socket.hpp:274
static Try< Address > create(const std::string &path)
Definition: address.hpp:210
Try< process::network::unix::Socket > createDomainSocket(const std::string &path, int mode=DOMAIN_SOCKET_DEFAULT_MODE)
Definition: domain_sockets.hpp:39
constexpr int DOMAIN_SOCKET_DEFAULT_MODE
Definition: domain_sockets.hpp:36
Definition: attributes.hpp:24
Try< mode_t > mode(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:168
Try< Netlink< struct nl_sock > > socket(int protocol=NETLINK_ROUTE)
Definition: internal.hpp:91