8 #include <netinet/in.h> 11 #include <xdrpp/rpcb_prot.hh> 21 return err == EAGAIN || err == EWOULDBLOCK || err == EINTR;
27 return std::strerror(errno);
33 throw std::system_error(errno, std::system_category(), msg);
37 read(
sock_t s,
void *buf, std::size_t count)
39 return ::read(s.fd(), buf, count);
43 write(
sock_t s,
const void *buf, std::size_t count)
45 return ::write(s.fd(), buf, count);
49 readv(
sock_t s,
const struct iovec *iov,
int iovcnt)
51 return ::readv(s.fd(), iov, iovcnt);
54 ssize_t writev(
sock_t s,
const struct iovec *iov,
int iovcnt)
56 return ::writev(s.fd(), iov, iovcnt);
62 while (::close(s.fd()) == -1)
64 std::cerr <<
"close: " <<
sock_errmsg() << std::endl;
73 if ((n = fcntl (s.fd_, F_GETFL)) == -1
74 || fcntl (s.fd_, F_SETFL, n | O_NONBLOCK) == -1)
82 if ((n = fcntl(s.fd_, F_GETFD)) == -1
83 || fcntl(s.fd_, F_SETFD, n | FD_CLOEXEC) == -1)
93 throw std::system_error(errno, std::system_category(),
"pipe");
void throw_sockerr(const char *)
Throw a system_error exception for the last socket error.
Most of the xdrpp library is encapsulated in the xdr namespace.
bool sock_eagain()
Returns true if the most recent (socket) error is a temporary error, such as EAGAIN, EWOULDBLOCK, or EINTR.
void set_nonblock(sock_t s)
Set the O_NONBLOCK flag on a socket.
Simple synchronous RPC functions.
const char * sock_errmsg()
Last socket error message (strerror(errno) on POSIX).
Abstract away the type of a socket (for windows).
void create_selfpipe(sock_t ss[2])
Create a socket (or pipe on unix, where both are file descriptors) that is connected to itself...
Simplified support for creating sockets.
void set_close_on_exec(sock_t s)
Set the close-on-exec flag of a file descriptor.