TSDuck v3.45-4686
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.
 

Public Attributes

size_t min_next_size = 0
 On return, the handler can specify in min_next_size the minimum data size to receive before being called again.
 
uint8_t next_delimiter = 0
 If next_min_size is set to NPOS, the returned byte value in next_delimiter is used as a delimiter for the next message.
 
size_t used_size = NPOS
 On return, the handler sets the number of bytes which were used in used_size.
 

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

size_t ts::ReactiveTCPInputControl::used_size = NPOS

On return, the handler sets 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.

On input, used_size is set to some value equal to or greater than the input data size, meaning that it is assumed that then handler uses the entire buffer. This means that used_size needs to be updated only if the handler doesn't use all input data in the buffer.

◆ min_next_size

size_t ts::ReactiveTCPInputControl::min_next_size = 0

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.

On input, min_next_size is set to zero, meaning that the handler will be called when any amount of data is available, including unused bytes if used_size is less than data size.

◆ next_delimiter

uint8_t ts::ReactiveTCPInputControl::next_delimiter = 0

If next_min_size is set to NPOS, the returned byte value in next_delimiter 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: