Kea  1.9.9-git
isc::http::HttpListener Class Reference

HTTP listener. More...

#include <listener.h>


struct  IdleTimeout
 Idle connection timeout. More...
struct  RequestTimeout
 HTTP request timeout value. More...

Public Member Functions

 HttpListener (asiolink::IOService &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. More...
 ~HttpListener ()
 Destructor. More...
asiolink::IOAddress getLocalAddress () const
 Returns local address on which server is listening. More...
uint16_t getLocalPort () const
 Returns local port on which server is listening. More...
void start ()
 Starts accepting new connections. More...
void stop ()
 Stops all active connections and shuts down the service. More...

Protected Attributes

boost::shared_ptr< HttpListenerImplimpl_
 Pointer to the implementation of the HttpListener. More...

Detailed Description

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.

Constructor & Destructor Documentation

isc::http::HttpListener::HttpListener ( asiolink::IOService 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 


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_serviceIO service to be used by the listener.
server_addressAddress on which the HTTP service should run.
server_portPort number on which the HTTP service should run.
tls_contextTLS context.
creator_factoryPointer to the caller-defined HttpResponseCreatorFactory derivation which should be used to create HttpResponseCreator instances.
request_timeoutTimeout after which the HTTP Request Timeout is generated.
idle_timeoutTimeout after which an idle persistent HTTP connection is closed by the server.
HttpListenerErrorwhen any of the specified parameters is invalid.

Definition at line 18 of file

isc::http::HttpListener::~HttpListener ( )


Stops all active connections and closes transport acceptor service.

Definition at line 31 of file

References stop().

+ Here is the call graph for this function:

Member Function Documentation

IOAddress isc::http::HttpListener::getLocalAddress ( ) const

Returns local address on which server is listening.

Definition at line 36 of file

References impl_.

uint16_t isc::http::HttpListener::getLocalPort ( ) const

Returns local port on which server is listening.

Definition at line 41 of file

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.

HttpListenerErrorif an error occurred.

Definition at line 46 of file

References impl_.

void isc::http::HttpListener::stop ( )

Stops all active connections and shuts down the service.

Definition at line 51 of file

References impl_.

Referenced by ~HttpListener().

Member Data Documentation

boost::shared_ptr<HttpListenerImpl> isc::http::HttpListener::impl_

Pointer to the implementation of the HttpListener.

Definition at line 135 of file listener.h.

Referenced by getLocalAddress(), getLocalPort(), start(), and stop().

The documentation for this class was generated from the following files: