Kea 2.7.4
isc::http::HttpListener Class Reference

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< HttpListenerImplimpl_
 Pointer to the implementation of the HttpListener.
 

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

◆ HttpListener()

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.

Parameters
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.
Exceptions
HttpListenerErrorwhen any of the specified parameters is invalid.

Definition at line 18 of file listener.cc.

◆ ~HttpListener()

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

Destructor.

Stops all active connections and closes transport acceptor service.

Definition at line 31 of file listener.cc.

References stop().

+ Here is the call graph for this function:

Member Function Documentation

◆ addExternalSockets()

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.

Parameters
use_externalTrue add external sockets (default false).

Definition at line 51 of file listener.cc.

References impl_.

◆ getLocalAddress()

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

Returns local address on which server is listening.

Definition at line 36 of file listener.cc.

References impl_.

◆ getLocalPort()

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_.

◆ getNative()

int isc::http::HttpListener::getNative ( ) const

file descriptor of the underlying acceptor socket.

Definition at line 46 of file listener.cc.

References impl_.

◆ start()

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.

Exceptions
HttpListenerErrorif an error occurred.

Definition at line 56 of file listener.cc.

References impl_.

◆ stop()

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().

Member Data Documentation

◆ impl_

boost::shared_ptr<HttpListenerImpl> isc::http::HttpListener::impl_
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().


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