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

Function test_callback

example/cpp11/operations/composed_2.cpp:136–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 3

async_write_messageFunction · 0.70
acceptMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected