 |
Kea
1.5.0
|
Go to the documentation of this file.
15 #include <boost/scoped_ptr.hpp>
49 const unsigned short server_port,
51 const long request_timeout,
52 const long idle_timeout);
85 void acceptHandler(
const boost::system::error_code& ec);
95 boost::scoped_ptr<asiolink::TCPEndpoint> endpoint_;
104 long request_timeout_;
111 HttpListenerImpl::HttpListenerImpl(
IOService& io_service,
113 const unsigned short server_port,
115 const long request_timeout,
116 const long idle_timeout)
117 : io_service_(io_service), acceptor_(io_service),
118 endpoint_(), creator_factory_(creator_factory),
119 request_timeout_(request_timeout), idle_timeout_(idle_timeout) {
122 endpoint_.reset(
new TCPEndpoint(server_address, server_port));
126 << server_address <<
":" << server_port);
130 if (!creator_factory_) {
136 if (request_timeout_ <= 0) {
138 << request_timeout_);
142 if (idle_timeout_ <= 0) {
144 " timeout " << idle_timeout_);
156 acceptor_.
open(*endpoint_);
158 acceptor_.
bind(*endpoint_);
161 }
catch (
const boost::system::system_error& ex) {
164 "listening to the incoming HTTP requests: " << ex.
what());
177 HttpListenerImpl::accept() {
183 boost::bind(&HttpListenerImpl::acceptHandler,
this, _1);
191 connections_.
start(conn);
195 HttpListenerImpl::acceptHandler(
const boost::system::error_code&) {
203 const unsigned short server_port,
208 creator_factory, request_timeout.value_,
209 idle_timeout.value_)) {
218 return (impl_->getEndpoint().getAddress());
223 return (impl_->getEndpoint().getPort());
The TCPEndpoint class is a concrete derived class of IOEndpoint that represents an endpoint of a TCP ...
void start()
Starts accepting new connections.
void close() const
Closes the acceptor.
The IOAddress class represents an IP addresses (version agnostic)
void start(const HttpConnectionPtr &connection)
Start new connection.
Pool of active HTTP connections.
boost::function< void(const boost::system::error_code &)> HttpAcceptorCallback
Type of the callback for the TCP acceptor used in this library.
The IOService class is a wrapper for the ASIO io_service class.
void bind(const EndpointType &endpoint)
Binds socket to an endpoint.
HttpListener(asiolink::IOService &io_service, const asiolink::IOAddress &server_address, const unsigned short server_port, const HttpResponseCreatorFactoryPtr &creator_factory, const RequestTimeout &request_timeout, const IdleTimeout &idle_timeout)
Constructor.
void stop()
Stops all active connections and shuts down the service.
void setOption(const SettableSocketOption &socket_option)
Sets socket option.
Implementation of the HttpListener.
A generic error raised by the HttpListener class.
Defines the logger used by the top-level component of kea-dhcp-ddns.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::asio::socket_base::reuse_address ReuseAddress
Represents SO_REUSEADDR socket option.
Accepts and handles a single HTTP connection.
asiolink::IOAddress getLocalAddress() const
Returns local address on which server is listening.
boost::shared_ptr< HttpResponseCreator > HttpResponseCreatorPtr
Pointer to the HttpResponseCreator object.
void listen()
Starts listening new connections.
uint16_t getLocalPort() const
Returns local port on which server is listening.
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
HTTP request timeout value.
const TCPEndpoint & getEndpoint() const
Returns reference to the current listener endpoint.
void open(const EndpointType &endpoint)
Opens acceptor socket given the endpoint.
void stopAll()
Stops all connections and removes them from the pool.
boost::shared_ptr< HttpConnection > HttpConnectionPtr
Pointer to the HttpConnection.
void start()
Starts accepting new connections.
void stop()
Stops all active connections and shuts down the service.
~HttpListener()
Destructor.