Kea 2.7.6
listener_impl.h
Go to the documentation of this file.
1// Copyright (C) 2019-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#ifndef HTTP_LISTENER_IMPL_H
8#define HTTP_LISTENER_IMPL_H
9
10#include <asiolink/io_service.h>
11#include <asiolink/io_address.h>
13#include <http/connection.h>
16#include <boost/enable_shared_from_this.hpp>
17#include <boost/scoped_ptr.hpp>
18
19namespace isc {
20namespace http {
21
23class HttpListenerImpl : public boost::enable_shared_from_this<HttpListenerImpl> {
24public:
25
49 const asiolink::IOAddress& server_address,
50 const unsigned short server_port,
51 const asiolink::TlsContextPtr& tls_context,
52 const HttpResponseCreatorFactoryPtr& creator_factory,
53 const long request_timeout,
54 const long idle_timeout);
55
58 }
59
62
65
67 int getNative() const;
68
75 void addExternalSockets(bool use_external);
76
86 void start();
87
89 void stop();
90
91protected:
92
97 void accept();
98
105 void acceptHandler(const boost::system::error_code& ec);
106
117 virtual HttpConnectionPtr createConnection(const HttpResponseCreatorPtr& response_creator,
118 const HttpAcceptorCallback& callback);
119
122
125
128
131 boost::scoped_ptr<asiolink::TCPEndpoint> endpoint_;
132
135
138
141
145
148};
149
150} // end of namespace isc::http
151} // end of namespace isc
152
153#endif // HTTP_LISTENER_IMPL_H
Implementation of the HttpListener.
bool use_external_
Use external sockets flag.
HttpListenerImpl(const asiolink::IOServicePtr &io_service, const asiolink::IOAddress &server_address, const unsigned short server_port, const asiolink::TlsContextPtr &tls_context, const HttpResponseCreatorFactoryPtr &creator_factory, const long request_timeout, const long idle_timeout)
Constructor.
long request_timeout_
Timeout for HTTP Request Timeout desired.
void start()
Starts accepting new connections.
boost::scoped_ptr< asiolink::TCPEndpoint > endpoint_
Pointer to the endpoint representing IP address and port on which the service is running.
long idle_timeout_
Timeout after which idle persistent connection is closed by the server.
HttpResponseCreatorFactoryPtr creator_factory_
Pointer to the HttpResponseCreatorFactory.
asiolink::IOServicePtr io_service_
Pointer to the IO service.
const asiolink::TCPEndpoint & getEndpoint() const
Returns reference to the current listener endpoint.
void accept()
Creates HttpConnection instance and adds it to the pool of active connections.
void addExternalSockets(bool use_external)
Use external sockets flag.
const asiolink::TlsContextPtr & getTlsContext() const
Returns reference to the current TLS context.
HttpAcceptorPtr acceptor_
Acceptor instance.
virtual ~HttpListenerImpl()
Virtual destructor.
int getNative() const
file descriptor of the underlying acceptor socket.
asiolink::TlsContextPtr tls_context_
TLS context.
virtual HttpConnectionPtr createConnection(const HttpResponseCreatorPtr &response_creator, const HttpAcceptorCallback &callback)
Creates an instance of the HttpConnection.
void acceptHandler(const boost::system::error_code &ec)
Callback invoked when the new connection is accepted.
HttpConnectionPoolPtr connections_
Pool of active connections.
void stop()
Stops all active connections and shuts down the service.
std::shared_ptr< HttpConnectionPool > HttpConnectionPoolPtr
Pointer to the HttpConnectionPool.
boost::shared_ptr< HttpResponseCreator > HttpResponseCreatorPtr
Pointer to the HttpResponseCreator object.
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
std::function< void(const boost::system::error_code &)> HttpAcceptorCallback
Type of the callback for the TCP acceptor used in this library.
boost::shared_ptr< HttpConnection > HttpConnectionPtr
Pointer to the HttpConnection.
Definition connection.h:41
boost::shared_ptr< HttpAcceptor > HttpAcceptorPtr
Type of shared pointer to TCP acceptors.
Defines the logger used by the top-level component of kea-lfc.