MCPcopy Create free account
hub / github.com/boostorg/asio / test

Function test

test/generic/raw_protocol.cpp:51–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void test()
52{
53 using namespace boost::asio;
54 namespace generic = boost::asio::generic;
55 typedef generic::raw_protocol rp;
56
57 const int af_inet = BOOST_ASIO_OS_DEF(AF_INET);
58 const int ipproto_icmp = BOOST_ASIO_OS_DEF(IPPROTO_ICMP);
59 const int sock_raw = BOOST_ASIO_OS_DEF(SOCK_RAW);
60
61 try
62 {
63 io_context ioc;
64 char mutable_char_buffer[128] = "";
65 const char const_char_buffer[128] = "";
66 socket_base::message_flags in_flags = 0;
67 socket_base::send_buffer_size socket_option;
68 socket_base::bytes_readable io_control_command;
69 archetypes::immediate_handler immediate;
70 boost::system::error_code ec;
71
72 // basic_raw_socket constructors.
73
74 rp::socket socket1(ioc);
75 rp::socket socket2(ioc, rp(af_inet, ipproto_icmp));
76 rp::socket socket3(ioc, rp::endpoint());
77#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
78 rp::socket::native_handle_type native_socket1
79 = ::socket(af_inet, sock_raw, 0);
80 rp::socket socket4(ioc, rp(af_inet, ipproto_icmp), native_socket1);
81#endif // !defined(BOOST_ASIO_WINDOWS_RUNTIME)
82
83 rp::socket socket5(std::move(socket4));
84 boost::asio::ip::icmp::socket icmp_socket(ioc);
85 rp::socket socket6(std::move(icmp_socket));
86
87 // basic_datagram_socket operators.
88
89 socket1 = rp::socket(ioc);
90 socket1 = std::move(socket2);
91 socket1 = boost::asio::ip::icmp::socket(ioc);
92
93 // I/O object functions.
94
95 rp::socket::executor_type ex = socket1.get_executor();
96 (void)ex;
97
98 // basic_socket functions.
99
100 rp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
101 (void)lowest_layer;
102
103 socket1.open(rp(af_inet, ipproto_icmp));
104 socket1.open(rp(af_inet, ipproto_icmp), ec);
105
106#if !defined(BOOST_ASIO_WINDOWS_RUNTIME)
107 rp::socket::native_handle_type native_socket2
108 = ::socket(af_inet, sock_raw, 0);

Callers

nothing calls this directly

Calls 15

bufferFunction · 0.85
endpointClass · 0.50
get_executorMethod · 0.45
openMethod · 0.45
assignMethod · 0.45
is_openMethod · 0.45
closeMethod · 0.45
native_handleMethod · 0.45
cancelMethod · 0.45
at_markMethod · 0.45
availableMethod · 0.45
bindMethod · 0.45

Tested by

no test coverage detected