]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/example/cpp03/http/server4/main.cpp
5 // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 #include <boost/asio.hpp>
13 #include <boost/bind.hpp>
16 #include "file_handler.hpp"
18 int main(int argc
, char* argv
[])
22 // Check command line arguments.
25 std::cerr
<< "Usage: http_server <address> <port> <doc_root>\n";
26 std::cerr
<< " For IPv4, try:\n";
27 std::cerr
<< " receiver 0.0.0.0 80 .\n";
28 std::cerr
<< " For IPv6, try:\n";
29 std::cerr
<< " receiver 0::0 80 .\n";
33 boost::asio::io_context io_context
;
35 // Launch the initial server coroutine.
36 http::server4::server(io_context
, argv
[1], argv
[2],
37 http::server4::file_handler(argv
[3]))();
39 // Wait for signals indicating time to shut down.
40 boost::asio::signal_set
signals(io_context
);
45 #endif // defined(SIGQUIT)
46 signals
.async_wait(boost::bind(
47 &boost::asio::io_context::stop
, &io_context
));
52 catch (std::exception
& e
)
54 std::cerr
<< "exception: " << e
.what() << "\n";