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

Function main

example/websocket/server/stackless/websocket_server_stackless.cpp:249–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247//------------------------------------------------------------------------------
248
249int main(int argc, char* argv[])
250{
251 // Check command line arguments.
252 if (argc != 4)
253 {
254 std::cerr <<
255 "Usage: websocket-server-stackless <address> <port> <threads>\n" <<
256 "Example:\n" <<
257 " websocket-server-stackless 0.0.0.0 8080 1\n";
258 return EXIT_FAILURE;
259 }
260 auto const address = net::ip::make_address(argv[1]);
261 auto const port = static_cast<unsigned short>(std::atoi(argv[2]));
262 auto const threads = std::max<int>(1, std::atoi(argv[3]));
263
264 // The io_context is required for all I/O
265 net::io_context ioc{threads};
266
267 // Create and launch a listening port
268 std::make_shared<listener>(ioc, tcp::endpoint{address, port})->run();
269
270 // Run the I/O service on the requested number of threads
271 std::vector<std::thread> v;
272 v.reserve(threads - 1);
273 for(auto i = threads - 1; i > 0; --i)
274 v.emplace_back(
275 [&ioc]
276 {
277 ioc.run();
278 });
279 ioc.run();
280
281 return EXIT_SUCCESS;
282}

Callers

nothing calls this directly

Calls 1

runMethod · 0.45

Tested by

no test coverage detected