MCPcopy Create free account
hub / github.com/alibaba/async_simple / start_server

Function start_server

demo_example/async_echo_server.cpp:50–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50async_simple::coro::Lazy<void> start_server(asio::io_context& io_context,
51 unsigned short port,
52 async_simple::Executor* E) {
53 tcp::acceptor a(io_context, tcp::endpoint(tcp::v4(), port));
54 std::cout << "Listen port " << port << " successfully.\n";
55 for (;;) {
56 tcp::socket socket(io_context);
57 auto error = co_await async_accept(a, socket);
58 if (error) {
59 std::cout << "Accept failed, error: " << error.message() << '\n';
60 continue;
61 }
62 std::cout << "New client coming.\n";
63 session(std::move(socket)).via(E).detach();
64 }
65}
66
67int main(int argc, char* argv[]) {
68 try {

Callers 1

mainFunction · 0.70

Calls 6

messageMethod · 0.80
viaMethod · 0.80
async_acceptFunction · 0.70
sessionFunction · 0.70
endpointFunction · 0.50
detachMethod · 0.45

Tested by

no test coverage detected