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

Function test_callback

example/cpp11/operations/composed_1.cpp:66–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 3

async_write_messageFunction · 0.70
acceptMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected