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

Function test_callback

example/cpp20/operations/composed_1.cpp:64–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 3

async_write_messageFunction · 0.70
acceptMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected