TSDuck v3.45-4725
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::ReactiveTCPInputControl Class Reference

The class describes input data, as provided by a ReactiveTCPConnection to a ReactiveTCPConnectionHandlerInterface. More...

#include <tsReactiveTCPInputControl.h>

Public Member Functions

 ReactiveTCPInputControl ()=default
 Default constructor.
 
void reset ()
 Reset the content to the original values, suitable for processing an input buffer.
 

Public Attributes

std::optional< size_t > min_next_size {}
 Minimum data size for next call.
 
std::optional< uint8_t > next_delimiter {}
 Required end-of-message delimiter for next call.
 
std::optional< size_t > used_size {}
 Number of used bytes in the handler.
 

Detailed Description

The class describes input data, as provided by a ReactiveTCPConnection to a ReactiveTCPConnectionHandlerInterface.

The handler updates the ReactiveTCPInputControl structure depending on its processing of the input data.

Sample scenario for ReactiveTCPConnectionHandlerInterface::handleTCPReceive(), using a message format consisting of a message header, containing the payload size, followed by a payload of that size.

  • If data size is less than the header size, set used_size to zero, set min_next_size to the expected header size, and return.
  • Otherwise, read the payload size in the header, check if the complete message, header and payload, is in the data buffer. If not, set used_size to zero, set min_next_size to the total message size, header and payload, then return.
  • Otherwise, process the message, set used_size to the total size of the processed message, set min_next_size to the expected header size (for next message), and return.

Sample scenario for ReactiveTCPConnectionHandlerInterface::handleTCPReceive(), using a text line format where each line is terminated by LF or a CR/LF combination.

  • Check if data contains a LF byte. If not, set used_size to zero, set min_next_size to NPOS, set next_delimiter to LF, and return.
  • Otherwise, process the text line up to and including the LF byte, set used_size to the processed line size, including the LF, set min_next_size to NPOS, set next_delimiter to LF, and return.

In all cases, the handler shall check error_code and verify that it is equal to SYS_SUCCESS before proceeding. Otherwise, the connection shall be considered as lost or terminated.

Member Data Documentation

◆ used_size

std::optional<size_t> ts::ReactiveTCPInputControl::used_size {}

Number of used bytes in the handler.

In input, used_size is unset. On return, the handler may set the number of bytes which were used in used_size. If the returned value of used_size is less than the input data size, the remaining unused data stay in the input buffer and will be present at the beginning of the data buffer the next time this handler will be called. If used_size is left unset, all input data are assumed to be used by the handler.

◆ min_next_size

std::optional<size_t> ts::ReactiveTCPInputControl::min_next_size {}

Minimum data size for next call.

In input, min_next_size is unset. On return, the handler can specify in min_next_size the minimum data size to receive before being called again. This is the minimum size of the data buffer, including remaining unused data when used_size is set to a value lower that data size. This means that if min_next_size is less than the remaining unused bytes in the buffer, the handler will be immediately called again on return.

◆ next_delimiter

std::optional<uint8_t> ts::ReactiveTCPInputControl::next_delimiter {}

Required end-of-message delimiter for next call.

In input, next_delimiter is unset. On return, if next_delimiter is set, its value is used as a delimiter for the next message. This means that the handler will be called again only when input data contains the corresponding byte value, including unused bytes if used_size is less than data size.


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