Kea  1.5.0
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 (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. 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...
 

Detailed Description

HTTP listener.

This class is an entry point to the use of HTTP services in Kea. It creates a TCP 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 51 of file listener.h.

Constructor & Destructor Documentation

◆ HttpListener()

isc::http::HttpListener::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.

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.
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 201 of file listener.cc.

◆ ~HttpListener()

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

Destructor.

Stops all active connections and closes TCP acceptor service.

Definition at line 212 of file listener.cc.

References stop().

+ Here is the call graph for this function:

Member Function Documentation

◆ getLocalAddress()

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

Returns local address on which server is listening.

Definition at line 217 of file listener.cc.

◆ getLocalPort()

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

Returns local port on which server is listening.

Definition at line 222 of file listener.cc.

◆ 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 227 of file listener.cc.

◆ stop()

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

Stops all active connections and shuts down the service.

Definition at line 232 of file listener.cc.

Referenced by ~HttpListener().


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