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

Function main

example/cpp20/invocation/completion_executor.cpp:54–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52//----------------------------------------------------------------------
53
54int main()
55{
56 boost::asio::io_context io_context(1);
57
58 // Post a completion handler to be run immediately.
59 boost::asio::post(io_context,
60 boost::asio::bind_executor(logging_executor{},
61 []{ std::cout << "post complete\n"; }));
62
63 // Start an asynchronous accept that will complete immediately.
64 tcp::endpoint endpoint(boost::asio::ip::address_v4::loopback(), 0);
65 tcp::acceptor acceptor(io_context, endpoint);
66 tcp::socket server_socket(io_context);
67 acceptor.async_accept(
68 boost::asio::bind_executor(logging_executor{},
69 [](auto...){ std::cout << "async_accept complete\n"; }));
70 tcp::socket client_socket(io_context);
71 client_socket.connect(acceptor.local_endpoint());
72
73 // Set a timer to expire immediately.
74 boost::asio::steady_timer timer(io_context);
75 timer.expires_at(boost::asio::steady_timer::clock_type::time_point::min());
76 timer.async_wait(
77 boost::asio::bind_executor(logging_executor{},
78 [](auto){ std::cout << "async_wait complete\n"; }));
79
80 io_context.run();
81
82 return 0;
83}

Callers

nothing calls this directly

Calls 7

postFunction · 0.50
async_acceptMethod · 0.45
connectMethod · 0.45
local_endpointMethod · 0.45
expires_atMethod · 0.45
async_waitMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected