Chops Net IP
Loading...
Searching...
No Matches
msg_handling_start_funcs.hpp
Go to the documentation of this file.
1
22#ifndef MSG_HANDLING_START_FUNCS_HPP_INCLUDED
23#define MSG_HANDLING_START_FUNCS_HPP_INCLUDED
24
25#include <string_view>
26#include <cstddef> // std::size_t, std::byte
27
28#include "asio/ip/udp.hpp" // udp endpoint
29
31
33
34namespace chops {
35namespace test {
36
37using tcp_msg_hdlr = msg_hdlr<chops::net::tcp_io>;
38using udp_msg_hdlr = msg_hdlr<chops::net::udp_io>;
39using tcp_fixed_size_msg_hdlr = fixed_size_msg_hdlr<chops::net::tcp_io>;
40using udp_fixed_size_msg_hdlr = fixed_size_msg_hdlr<chops::net::udp_io>;
41
42inline auto tcp_start_io (chops::net::tcp_io_interface io, bool reply,
43 std::string_view delim, test_counter& cnt) {
44 return delim.empty() ?
45 io.start_io(2, tcp_msg_hdlr(reply, cnt), decode_variable_len_msg_hdr) :
46 io.start_io(delim, tcp_msg_hdlr(reply, cnt));
47}
48
49constexpr int udp_max_buf_size = 65507;
50
51inline auto udp_start_io (chops::net::udp_io_interface io, bool reply, test_counter& cnt) {
52 return io.start_io(udp_max_buf_size, udp_msg_hdlr(reply, cnt));
53}
54
55inline auto udp_start_io (chops::net::udp_io_interface io, bool receiving, test_counter& cnt,
56 const asio::ip::udp::endpoint& remote_endp) {
57 return receiving ?
58 io.start_io(remote_endp, udp_max_buf_size, udp_msg_hdlr(false, cnt)) :
59 io.start_io(remote_endp);
60}
61
62inline asio::ip::udp::endpoint make_udp_endpoint(const char* addr, int port_num) {
63 return asio::ip::udp::endpoint(asio::ip::make_address(addr),
64 static_cast<unsigned short>(port_num));
65}
66
67} // end namespace test
68} // end namespace chops
69
70
71#endif
72
IO type declarations, relating to the basic_io_interface and basic_io_output class templates.
Declarations and implementations for shared test code dealing with test message building and message ...
Definition tcp_dsr.cpp:96