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

Function test_callback

example/cpp14/operations/composed_1.cpp:62–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60//------------------------------------------------------------------------------
61
62void test_callback()
63{
64 boost::asio::io_context io_context;
65
66 tcp::acceptor acceptor(io_context, {tcp::v4(), 55555});
67 tcp::socket socket = acceptor.accept();
68
69 // Test our asynchronous operation using a lambda as a callback.
70 async_write_message(socket, "Testing callback\r\n",
71 [](const boost::system::error_code& error, std::size_t n)
72 {
73 if (!error)
74 {
75 std::cout << n << " bytes transferred\n";
76 }
77 else
78 {
79 std::cout << "Error: " << error.message() << "\n";
80 }
81 });
82
83 io_context.run();
84}
85
86//------------------------------------------------------------------------------
87

Callers 1

mainFunction · 0.70

Calls 3

async_write_messageFunction · 0.70
acceptMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected