xdrpp
RFC4506 XDR compiler and message library
Public Types | Public Member Functions | Static Public Attributes | List of all members
xdr::msg_sock Class Reference

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_sockoperator= (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...
 
pollsetget_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
 

Detailed Description

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.

Definition at line 27 of file msgsock.h.

Member Function Documentation

◆ destroyed_ptr()

std::shared_ptr<const bool> xdr::msg_sock::destroyed_ptr ( ) const
inline

Returns pointer to a bool that becomes true once the msg_sock has been deleted.

Definition at line 51 of file msgsock.h.

◆ get_sock()

sock_t xdr::msg_sock::get_sock ( ) const
inline

Returns the socket, but do not do IO on it.

This is just for calling things like getpeername.

Definition at line 55 of file msgsock.h.


The documentation for this class was generated from the following files: