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

Function main

example/http/server/stackless/http_server_stackless.cpp:420–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418//------------------------------------------------------------------------------
419
420int main(int argc, char* argv[])
421{
422 // Check command line arguments.
423 if (argc != 5)
424 {
425 std::cerr <<
426 "Usage: http-server-stackless <address> <port> <doc_root> <threads>\n" <<
427 "Example:\n" <<
428 " http-server-stackless 0.0.0.0 8080 . 1\n";
429 return EXIT_FAILURE;
430 }
431 auto const address = net::ip::make_address(argv[1]);
432 auto const port = static_cast<unsigned short>(std::atoi(argv[2]));
433 auto const doc_root = std::make_shared<std::string>(argv[3]);
434 auto const threads = std::max<int>(1, std::atoi(argv[4]));
435
436 // The io_context is required for all I/O
437 net::io_context ioc{threads};
438
439 // Create and launch a listening port
440 std::make_shared<listener>(
441 ioc,
442 tcp::endpoint{address, port},
443 doc_root)->run();
444
445 // Run the I/O service on the requested number of threads
446 std::vector<std::thread> v;
447 v.reserve(threads - 1);
448 for(auto i = threads - 1; i > 0; --i)
449 v.emplace_back(
450 [&ioc]
451 {
452 ioc.run();
453 });
454 ioc.run();
455
456 return EXIT_SUCCESS;
457}

Callers

nothing calls this directly

Calls 1

runMethod · 0.45

Tested by

no test coverage detected