5 // Copyright (c) 2003-2014 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)
11 #ifndef HTTP_SERVER_HPP
12 #define HTTP_SERVER_HPP
14 #include <boost/asio.hpp>
16 #include "connection.hpp"
17 #include "connection_manager.hpp"
18 #include "request_handler.hpp"
23 /// The top-level class of the HTTP server.
27 server(const server&) = delete;
28 server& operator=(const server&) = delete;
30 /// Construct the server to listen on the specified TCP address and port, and
31 /// serve up files from the given directory.
32 explicit server(const std::string& address, const std::string& port,
33 const std::string& doc_root);
35 /// Run the server's io_service loop.
39 /// Perform an asynchronous accept operation.
42 /// Wait for a request to stop the server.
45 /// The io_service used to perform asynchronous operations.
46 boost::asio::io_service io_service_;
48 /// The signal_set is used to register for process termination notifications.
49 boost::asio::signal_set signals_;
51 /// Acceptor used to listen for incoming connections.
52 boost::asio::ip::tcp::acceptor acceptor_;
54 /// The connection manager which owns all live connections.
55 connection_manager connection_manager_;
57 /// The next socket to be accepted.
58 boost::asio::ip::tcp::socket socket_;
60 /// The handler for all incoming requests.
61 request_handler request_handler_;
67 #endif // HTTP_SERVER_HPP