xdrpp
RFC4506 XDR compiler and message library
|
Send and receive a series of delimited messages on a stream socket. More...
#include <msgsock.h>
Public Types | |
using | rcb_t = std::function< void(msg_ptr)> |
Public Member Functions | |
template<typename T > | |
msg_sock (pollset &ps, sock_t s, T &&rcb, size_t maxmsglen=default_maxmsglen) | |
msg_sock (pollset &ps, sock_t s) | |
msg_sock & | operator= (msg_sock &&)=delete |
template<typename T > | |
void | setrcb (T &&rcb) |
size_t | wsize () const |
void | putmsg (msg_ptr &b) |
void | putmsg (msg_ptr &&b) |
std::shared_ptr< const bool > | destroyed_ptr () const |
Returns pointer to a bool that becomes true once the msg_sock has been deleted. More... | |
pollset & | get_pollset () |
sock_t | get_sock () const |
Returns the socket, but do not do IO on it. More... | |
Static Public Attributes | |
static constexpr std::size_t | default_maxmsglen = 0x100000 |
Send and receive a series of delimited messages on a stream socket.
The format (specified in RFC5531, Section 11) is simple: A 4-byte length (in little-endian format) followed by that many bytes. The implementation is optimized for having many sockets each receiving a small number of messages, as opposed to receiving many messages over the same socket.
Currently this calls read once or twice per message to get the exact length before allocating buffer space and reading the message body (possibly including the next message length). This could be fixed to read at least a little bit more data speculatively and reduce the number of system calls.
|
inline |
|
inline |