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

Functions that create IO state change function objects used in the net_entity start method, each will invoke start_io. More...

#include <cstddef>
#include <utility>
#include "asio/ip/udp.hpp"
#include "net_ip/io_type_decls.hpp"
#include "net_ip/simple_variable_len_msg_frame.hpp"
Include dependency graph for io_state_change.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename MH >
auto chops::net::make_simple_variable_len_msg_frame_io_state_change (std::size_t hdr_size, MH &&msg_hdlr, hdr_decoder_func hdr_func)
 Create an IO state change function object with a simple variable length message frame function object for TCP reads.
 
template<typename MH , typename MF >
auto chops::net::make_msg_frame_io_state_change (std::size_t hdr_size, MH &&msg_hdlr, MF &&msg_frame)
 Create an IO state change function object that is fully templatized on the message frame function object, versus a simple variable len message frame.
 
template<typename MH >
auto chops::net::make_delimiter_read_io_state_change (std::string_view delim, MH &&msg_hdlr)
 Create an IO state change function object parameters for TCP delimited reads.
 
template<typename MH , typename IOT = udp_io>
auto chops::net::make_read_io_state_change (std::size_t rd_size, MH &&msg_hdlr)
 Create an IO state change function object with parameters for UDP reads or fixed size TCP reads.
 
template<typename IOT >
auto chops::net::make_send_only_io_state_change ()
 Create an IO state change function object with parameters for sending only, whether UDP or TCP.
 
template<typename MH >
auto chops::net::make_default_endp_io_state_change (const asio::ip::udp::endpoint &endp, std::size_t max_size, MH &&msg_hdlr)
 Create an IO state change function object parameters for UDP senders and receivers with a default destination endpoint.
 
auto chops::net::make_send_only_default_endp_io_state_change (const asio::ip::udp::endpoint &endp)
 Create an IO state change function object parameters for UDP sending only with a default destination endpoint.
 

Detailed Description

Functions that create IO state change function objects used in the net_entity start method, each will invoke start_io.

The common logic in each of these function objects is calling start_io on an io_interface after start has been called on a net_entity.

In general, there is a creation function corresponding to each overload of the start_io method of basic_io_interface.

Most of these functions are templated on the message handler class, which is different for every application.

Note
None of these IO state change function object perform any action on IO stop or shutdown.
These creation functions are not a necessary dependency of the net_ip core library, but are useful components for many applications.
Author
Cliff Green

Copyright (c) 2018-2019 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)

Function Documentation

◆ make_default_endp_io_state_change()

template<typename MH >
auto chops::net::make_default_endp_io_state_change ( const asio::ip::udp::endpoint & endp,
std::size_t max_size,
MH && msg_hdlr )

Create an IO state change function object parameters for UDP senders and receivers with a default destination endpoint.

Parameters
endpDefault destination asio::ip::udp::endpoint.
max_sizeMaximum buffer size for UDP reads.
msg_hdlrA function object that can be used as a message handler in the start_io method.
Returns
A function object that can be used with the start method.
Note
This is implemented only for UDP processing.

◆ make_delimiter_read_io_state_change()

template<typename MH >
auto chops::net::make_delimiter_read_io_state_change ( std::string_view delim,
MH && msg_hdlr )

Create an IO state change function object parameters for TCP delimited reads.

The IO state change function object created does not perform any actions on IO stop.

Parameters
delimDelimiter for the TCP reads.
msg_hdlrA function object that can be used as a message handler in the start_io method.
Returns
A function object that can be used with the start method.
Note
This is implemented only for TCP connections.

◆ make_msg_frame_io_state_change()

template<typename MH , typename MF >
auto chops::net::make_msg_frame_io_state_change ( std::size_t hdr_size,
MH && msg_hdlr,
MF && msg_frame )

Create an IO state change function object that is fully templatized on the message frame function object, versus a simple variable len message frame.

Parameters
hdr_sizeSize in bytes of message header.
msg_hdlrA function object that can be used as a message handler in the start_io method.
msg_frameA function object that can be used as a message frame in the start_io method.
Returns
A function object that can be used with the start method.
Note
This is implemented only for TCP connections.

◆ make_read_io_state_change()

template<typename MH , typename IOT = udp_io>
auto chops::net::make_read_io_state_change ( std::size_t rd_size,
MH && msg_hdlr )

Create an IO state change function object with parameters for UDP reads or fixed size TCP reads.

The IO type is defaulted to UDP, since fixed size TCP reads are a much less common use case.

Parameters
rd_sizeMaximum buffer size for UDP reads or size of each TCP read.
msg_hdlrA function object that can be used as a message handler in the start_io method.
Returns
A function object that can be used with the start method.

◆ make_send_only_default_endp_io_state_change()

auto chops::net::make_send_only_default_endp_io_state_change ( const asio::ip::udp::endpoint & endp)
inline

Create an IO state change function object parameters for UDP sending only with a default destination endpoint.

Parameters
endpDefault destination asio::ip::udp::endpoint.
Returns
A function object that can be used with the start method.
Note
This is implemented only for UDP processing.

◆ make_send_only_io_state_change()

template<typename IOT >
auto chops::net::make_send_only_io_state_change ( )

Create an IO state change function object with parameters for sending only, whether UDP or TCP.

Returns
A function object that can be used with the start method.

◆ make_simple_variable_len_msg_frame_io_state_change()

template<typename MH >
auto chops::net::make_simple_variable_len_msg_frame_io_state_change ( std::size_t hdr_size,
MH && msg_hdlr,
hdr_decoder_func hdr_func )

Create an IO state change function object with a simple variable length message frame function object for TCP reads.

Parameters
hdr_sizeSize in bytes of message header.
hdr_funcHeader decoder function pointer, as described in hdr_decoder_func.
msg_hdlrA function object that can be used as a message handler in the start_io method.
Returns
A function object that can be used with the start method.
Note
This is implemented only for TCP connections.