11 bool xdr_trace_client = std::getenv(
"XDR_TRACE_CLIENT");
14 read_message(sock_t s)
17 ssize_t n = read(s, &len, 4);
19 throw xdr_system_error(
"xdr::read_message");
21 throw xdr_bad_message_size(
"read_message: premature EOF");
23 throw xdr_bad_message_size(
"read_message: received size not multiple of 4");
25 throw xdr_bad_message_size(
"read_message: received size too big");
31 throw xdr_bad_message_size(
"read_message: message fragments unimplemented");
34 n = read(s, m->data(), len);
36 throw xdr_system_error(
"xdr::read_message");
38 throw xdr_bad_message_size(
"read_message: premature EOF");
44 write_message(sock_t s,
const msg_ptr &m)
46 ssize_t n = write(s, m->raw_data(), m->raw_size());
48 throw xdr_system_error(
"xdr::write_message");
52 assert(std::size_t(n) == m->raw_size());
58 prepare_call(uint32_t prog, uint32_t vers, uint32_t proc, rpc_msg &hdr)
60 hdr.xid = ++xid_counter;
62 hdr.body.cbody().rpcvers = 2;
63 hdr.body.cbody().prog = prog;
64 hdr.body.cbody().vers = vers;
65 hdr.body.cbody().proc = proc;
72 dispatch(
nullptr, read_message(s_),
73 std::bind(write_message, s_, std::placeholders::_1));
static msg_ptr alloc(std::size_t size)
Allocate a new buffer.
Most of the xdrpp library is encapsulated in the xdr namespace.
Constexpr std::uint32_t swap32le(std::uint32_t v)
Byteswap 32-bit value only on little-endian machines, identity function on big-endian machines...
Exceptions raised by RPC calls.
Simple synchronous RPC functions.
void run()
Start serving requests. (Loops until an exception.)