![]() |
Kea 2.7.3
|
HTTP listener. More...
#include <listener.h>
Classes | |
struct | IdleTimeout |
Idle connection timeout. More... | |
struct | RequestTimeout |
HTTP request timeout value. More... | |
Public Member Functions | |
HttpListener (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 RequestTimeout &request_timeout, const IdleTimeout &idle_timeout) | |
Constructor. | |
~HttpListener () | |
Destructor. | |
void | addExternalSockets (bool use_external=false) |
Use external sockets flag. | |
asiolink::IOAddress | getLocalAddress () const |
Returns local address on which server is listening. | |
uint16_t | getLocalPort () const |
Returns local port on which server is listening. | |
int | getNative () const |
file descriptor of the underlying acceptor socket. | |
void | start () |
Starts accepting new connections. | |
void | stop () |
Stops all active connections and shuts down the service. | |
Protected Attributes | |
boost::shared_ptr< HttpListenerImpl > | impl_ |
Pointer to the implementation of the HttpListener. | |
HTTP listener.
This class is an entry point to the use of HTTP services in Kea. It creates a transport acceptor service on the specified address and port and listens to the incoming HTTP connections. The constructor receives a pointer to the implementation of the HttpResponseCreatorFactory, which is used by the HttpListener to create/retrieve an instance of the HttpResponseCreator when the new HTTP response needs to be generated. The HttpResponseCreator creates an object derived from the HttpResponse class, encapsulating a HTTP response following some specific rules, e.g. having "application/json" content type.
When the listener is started it creates an instance of a HttpConnection and stores them in the pool of active connections. The HttpConnection is responsible for managing the next connection received and receiving the HTTP request and sending appropriate response. The listener can handle many HTTP connections simultaneously.
When the HttpListener::stop is invoked, all active connections are closed and the listener stops accepting new connections.
Definition at line 52 of file listener.h.
isc::http::HttpListener::HttpListener | ( | 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 RequestTimeout & | request_timeout, | ||
const IdleTimeout & | idle_timeout ) |
Constructor.
This constructor creates new server endpoint using the specified IP address and port. It also validates other specified parameters.
This constructor does not start accepting new connections! To start accepting connections run HttpListener::start.
io_service | IO service to be used by the listener. |
server_address | Address on which the HTTP service should run. |
server_port | Port number on which the HTTP service should run. |
tls_context | TLS context. |
creator_factory | Pointer to the caller-defined HttpResponseCreatorFactory derivation which should be used to create HttpResponseCreator instances. |
request_timeout | Timeout after which the HTTP Request Timeout is generated. |
idle_timeout | Timeout after which an idle persistent HTTP connection is closed by the server. |
HttpListenerError | when any of the specified parameters is invalid. |
Definition at line 18 of file listener.cc.
isc::http::HttpListener::~HttpListener | ( | ) |
Destructor.
Stops all active connections and closes transport acceptor service.
Definition at line 31 of file listener.cc.
References stop().
void isc::http::HttpListener::addExternalSockets | ( | bool | use_external = false | ) |
Use external sockets flag.
Add sockets as external sockets of the interface manager so available I/O on them makes a waiting select to return.
use_external | True add external sockets (default false). |
Definition at line 51 of file listener.cc.
References impl_.
IOAddress isc::http::HttpListener::getLocalAddress | ( | ) | const |
Returns local address on which server is listening.
Definition at line 36 of file listener.cc.
References impl_.
uint16_t isc::http::HttpListener::getLocalPort | ( | ) | const |
Returns local port on which server is listening.
Definition at line 41 of file listener.cc.
References impl_.
int isc::http::HttpListener::getNative | ( | ) | const |
file descriptor of the underlying acceptor socket.
Definition at line 46 of file listener.cc.
References impl_.
void isc::http::HttpListener::start | ( | ) |
Starts accepting new connections.
This method starts accepting and handling new HTTP connections on the IP address and port number specified in the constructor.
If the method is invoked successfully, it must not be invoked again until HttpListener::stop is called.
HttpListenerError | if an error occurred. |
Definition at line 56 of file listener.cc.
References impl_.
void isc::http::HttpListener::stop | ( | ) |
Stops all active connections and shuts down the service.
Definition at line 61 of file listener.cc.
References impl_.
Referenced by ~HttpListener().
|
protected |
Pointer to the implementation of the HttpListener.
Definition at line 146 of file listener.h.
Referenced by addExternalSockets(), getLocalAddress(), getLocalPort(), getNative(), start(), and stop().