Chops Net IP
Loading...
Searching...
No Matches
msg_handling.hpp File Reference

Declarations and implementations for shared test code dealing with test message building and message handler function object classes. More...

#include <string_view>
#include <cstddef>
#include <cstdint>
#include <vector>
#include <utility>
#include <atomic>
#include <ostream>
#include <chrono>
#include <thread>
#include <future>
#include <ranges>
#include <cassert>
#include <limits>
#include "asio/buffer.hpp"
#include "asio/ip/udp.hpp"
#include "asio/ip/address.hpp"
#include "utility/byte_array.hpp"
#include "serialize/extract_append.hpp"
#include "buffer/shared_buffer.hpp"
#include "net_ip/basic_io_output.hpp"
#include "net_ip/queue_stats.hpp"
Include dependency graph for msg_handling.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  chops::test::msg_hdlr< IOT >
 
struct  chops::test::fixed_size_msg_hdlr< IOT >
 
class  chops::test::poll_output_queue_cond
 

Typedefs

using chops::test::vec_buf = std::vector<chops::const_shared_buffer>
 
using chops::test::test_counter = std::atomic_size_t
 
using chops::test::test_prom = std::promise<std::size_t>
 

Functions

std::size_t chops::test::decode_variable_len_msg_hdr (const std::byte *buf_ptr, std::size_t sz)
 
chops::mutable_shared_buffer chops::test::make_body_buf (std::string_view pre, char body_char, std::size_t num_body_chars)
 
chops::const_shared_buffer chops::test::make_variable_len_msg (const chops::mutable_shared_buffer &body)
 
chops::const_shared_buffer chops::test::make_cr_lf_text_msg (const chops::mutable_shared_buffer &body)
 
chops::const_shared_buffer chops::test::make_lf_text_msg (const chops::mutable_shared_buffer &body)
 
template<typename F >
chops::const_shared_buffer chops::test::make_empty_body_msg (F &&func)
 
auto chops::test::make_empty_variable_len_msg ()
 
auto chops::test::make_empty_cr_lf_text_msg ()
 
auto chops::test::make_empty_lf_text_msg ()
 
template<typename F >
vec_buf chops::test::make_msg_vec (F &&func, std::string_view pre, char body_char, int num_msgs)
 
chops::const_shared_buffer chops::test::make_fixed_size_buf ()
 
vec_buf chops::test::make_fixed_size_msg_vec (int num_msgs)
 

Variables

constexpr std::size_t chops::test::fixed_size_buf_size = 33u
 

Detailed Description

Declarations and implementations for shared test code dealing with test message building and message handler function object classes.

There are a couple of message handling designs shared between the unit tests. One is a variable length message, encoded three ways - with a binary length header, a LF delimited text, and a CR / LF delimited text. The other other is a fixed-size message.

The general Chops Net IP test strategy for the variable length messages is to have message senders and message receivers, with a flag specifying whether the receiver is to loop back the messages. For TCP it is independent of whether the sender or receiver is an acceptor or connector, although most tests have the connector being a sender. In the test routines, coordination is typically needed to know when a connection has been made or sender / receiver is ready so that message flow can start. At the higher layers, the Chops Net IP library facilities provide connection state change function object callbacks.

When the message flow is finished, an empty body message is sent to the receiver (and looped back if the reply flag is set), which signals an "end of message flow" condition. The looped back empty message may not arrive back to the sender since connections or handlers are in the process of being taken down.

The fixed-size messages use a simpler messsage flow design, with no "end of message" indication. This requires a higher layer to bring down the connections and finish processing.

Author
Cliff Green

Copyright (c) 2017-2025 by Cliff Green

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)