C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::net::lp::framing Class Reference

Implements length-prefix framing for discretizing a Byte stream into messages of varying size. More...

#include <framing.hpp>

Inheritance diagram for caf::net::lp::framing:
caf::net::octet_stream::upper_layer caf::net::lp::lower_layer caf::net::generic_upper_layer caf::net::generic_lower_layer

Public Types

using upper_layer_ptr = std::unique_ptr<lp::upper_layer>
 

Static Public Member Functions

static std::unique_ptr< framingmake (upper_layer_ptr up)
 
static disposable run (multiplexer &mpx, stream_socket fd, async::consumer_resource< chunk > pull, async::producer_resource< chunk > push)
 
static disposable run (multiplexer &mpx, ssl::connection conn, async::consumer_resource< chunk > pull, async::producer_resource< chunk > push)
 

Additional Inherited Members

- Public Member Functions inherited from caf::net::octet_stream::upper_layer
virtual error start (lower_layer *down)=0
 Initializes the upper layer.
 
virtual ptrdiff_t consume (byte_span buffer, byte_span delta)=0
 Consumes bytes from the lower layer.
 
virtual void written (size_t num_bytes)
 Called from the lower layer whenever data has been written.
 
- Public Member Functions inherited from caf::net::generic_upper_layer
virtual void prepare_send ()=0
 Gives the upper layer an opportunity to add additional data to the output buffer.
 
virtual bool done_sending ()=0
 Queries whether all pending data has been sent.
 
virtual void abort (const error &reason)=0
 Called by the lower layer for cleaning up any state in case of an error or when disposed.
 
- Public Member Functions inherited from caf::net::lp::lower_layer
virtual void request_messages ()=0
 Pulls messages from the transport until calling suspend_reading.
 
virtual void suspend_reading ()=0
 Stops reading messages until calling request_messages.
 
virtual void begin_message ()=0
 Prepares the layer for an outgoing message, e.g., by allocating an output buffer as necessary.
 
virtual byte_buffermessage_buffer ()=0
 Returns a reference to the buffer for assembling the current message.
 
virtual bool end_message ()=0
 Seals and prepares a message for transfer.
 
- Public Member Functions inherited from caf::net::generic_lower_layer
multiplexermpx () noexcept
 Returns the multiplexer instance that executes this protocol stack.
 
virtual socket_managermanager () noexcept=0
 Returns the manager that owns this layer.
 
virtual bool can_send_more () const noexcept=0
 Queries whether the output device can accept more data straight away.
 
virtual bool is_reading () const noexcept=0
 Queries whether the lower layer is currently reading from its input device.
 
virtual void write_later ()=0
 Triggers a write callback after the write device signals downstream capacity.
 
virtual void shutdown ()=0
 Shuts down any connection or session gracefully.
 
virtual void shutdown (const error &reason)
 Shuts down any connection or session due to an error.
 

Detailed Description

Implements length-prefix framing for discretizing a Byte stream into messages of varying size.

The framing uses 4 Bytes for the length prefix, but messages (including the 4 Bytes for the length prefix) are limited to a maximum size of INT32_MAX. This limitation comes from the POSIX API (recv) on 32-bit platforms.


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