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

Function test_callback

example/cpp20/operations/composed_2.cpp:132–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130//------------------------------------------------------------------------------
131
132void test_callback()
133{
134 boost::asio::io_context io_context;
135
136 tcp::acceptor acceptor(io_context, {tcp::v4(), 55555});
137 tcp::socket socket = acceptor.accept();
138
139 // Test our asynchronous operation using a lambda as a callback.
140 async_write_message(socket, "Testing callback\r\n", false,
141 [](const boost::system::error_code& error, std::size_t n)
142 {
143 if (!error)
144 {
145 std::cout << n << " bytes transferred\n";
146 }
147 else
148 {
149 std::cout << "Error: " << error.message() << "\n";
150 }
151 });
152
153 io_context.run();
154}
155
156//------------------------------------------------------------------------------
157

Callers 1

mainFunction · 0.70

Calls 3

async_write_messageFunction · 0.70
acceptMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected