23 #include <boost/thread.hpp> 40 , acceptor(io_service)
49 #endif // defined(SIGQUIT) 60 boost::asio::ip::tcp::resolver resolver(
io_service);
61 boost::asio::ip::tcp::resolver::query query(
65 boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
67 acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(
true));
70 }
catch (boost::system::system_error ex) {
71 LOG_SEV(server_log, error) <<
"Invalid host name: " << ex.what()
79 LOG_SEV(server_log, info) <<
"Server is now waiting for new connections ...";
80 LOG_SEV(server_log, info) <<
"Send a \"SIGINT\", \"SIGTERM\" or \"SIGQUIT\" signal to shut down the server. (ctrl-c)";
void stopRequest(shared_ptr< HttpRequest > request)
Stops a HttpRequest and deletes it from the request list.
static const char * server_address
Address of the server (type: string)
shared_ptr< Configuration > config
TESTABLE void quit()
Cleans up the HttpServer.
std::set< shared_ptr< HttpRequest > > requests
The managed requests.
#define LOG_SEV(log, lvl)
void start_accept()
Prepares the HttpServer for a new connection and waits asynchronous for it.
TESTABLE void listen()
The HttpServer starts listening for new connections.
boost::asio::ip::tcp::acceptor acceptor
Acceptor used to listen for incoming requests.
boost::asio::signal_set signals
The signal_set is used to register process termination notifications.
static const shared_ptr< Statistic > & Get()
shared_ptr< HttpRequest > nextRequest
The next connection to be accepted.
static const char * config
Option to get the configuration filename (type: string)
HttpServer(const shared_ptr< Configuration > &config, const shared_ptr< RequestManager > &manager)
This file is part of alaCarte.
void close()
Stop all asynchronous operations associated with the connection.
shared_ptr< RequestManager > manager
boost::asio::io_service io_service
The io_service used to perform asynchronous operations.
static const char * server_port
Port the server should listen at (type: int)
void handle_accept(const boost::system::error_code &e)
Called when a new client connects to the server.