Kea: listener.h Source File

| Kea 1.5.0

listener.h
Go to the documentation of this file.
1// Copyright (C) 2017 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_H
8#define HTTP_LISTENER_H
9
10#include <asiolink/io_address.h>
11#include <asiolink/io_service.h>
12#include <exceptions/exceptions.h>
13#include <http/response_creator_factory.h>
14#include <boost/shared_ptr.hpp>
15#include <stdint.h>
16
17namespace isc {
18namespace http {
19
21 class HttpListenerError : public Exception {
22public:
23 HttpListenerError(const char* file, size_t line, const char* what) :
24 isc::Exception(file, line, what) { };
25};
26
28class HttpListenerImpl;
29
51 class HttpListener {
52public:
53
55 struct RequestTimeout {
59 explicit RequestTimeout(long value)
60 : value_(value) {
61 }
62 long value_;
63 };
64
66 struct IdleTimeout {
70 explicit IdleTimeout(long value)
71 : value_(value) {
72 }
73 long value_;
74 };
75
97 HttpListener(asiolink::IOService& io_service,
98 const asiolink::IOAddress& server_address,
99 const unsigned short server_port,
100 const HttpResponseCreatorFactoryPtr& creator_factory,
101 const RequestTimeout& request_timeout,
102 const IdleTimeout& idle_timeout);
103
107 ~HttpListener();
108
110 asiolink::IOAddress getLocalAddress() const;
111
113 uint16_t getLocalPort() const;
114
124 void start();
125
127 void stop();
128
129private:
130
132 boost::shared_ptr<HttpListenerImpl> impl_;
133
134};
135
137 typedef boost::shared_ptr<HttpListener> HttpListenerPtr;
138
140 typedef boost::shared_ptr<const HttpListener> ConstHttpListenerPtr;
141
142} // end of namespace isc::http
143} // end of namespace isc
144
145#endif
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
isc::Exception::what
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
Definition: exceptions/exceptions.cc:32
isc::asiolink::IOAddress
The IOAddress class represents an IP addresses (version agnostic)
Definition: io_address.h:45
isc::asiolink::IOService
The IOService class is a wrapper for the ASIO io_service class.
Definition: io_service.h:31
isc::http::HttpListenerError
A generic error raised by the HttpListener class.
Definition: listener.h:21
isc::http::HttpListenerError::HttpListenerError
HttpListenerError(const char *file, size_t line, const char *what)
Definition: listener.h:23
isc::http::HttpListener
HTTP listener.
Definition: listener.h:51
isc::http::HttpListener::getLocalPort
uint16_t getLocalPort() const
Returns local port on which server is listening.
Definition: listener.cc:222
isc::http::HttpListener::getLocalAddress
asiolink::IOAddress getLocalAddress() const
Returns local address on which server is listening.
Definition: listener.cc:217
isc::http::HttpListener::~HttpListener
~HttpListener()
Destructor.
Definition: listener.cc:212
isc::http::HttpListener::stop
void stop()
Stops all active connections and shuts down the service.
Definition: listener.cc:232
isc::http::HttpListener::start
void start()
Starts accepting new connections.
Definition: listener.cc:227
exceptions.h
io_address.h
io_service.h
isc::http::ConstHttpListenerPtr
boost::shared_ptr< const HttpListener > ConstHttpListenerPtr
Pointer to the const HttpListener.
Definition: listener.h:140
isc::http::HttpListenerPtr
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
Definition: listener.h:137
isc::http::HttpResponseCreatorFactoryPtr
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
Definition: response_creator_factory.h:54
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
response_creator_factory.h
isc::http::HttpListener::IdleTimeout
Idle connection timeout.
Definition: listener.h:66
isc::http::HttpListener::IdleTimeout::value_
long value_
Connection idle timeout value specified.
Definition: listener.h:73
isc::http::HttpListener::IdleTimeout::IdleTimeout
IdleTimeout(long value)
Constructor.
Definition: listener.h:70
isc::http::HttpListener::RequestTimeout
HTTP request timeout value.
Definition: listener.h:55
isc::http::HttpListener::RequestTimeout::RequestTimeout
RequestTimeout(long value)
Constructor.
Definition: listener.h:59
isc::http::HttpListener::RequestTimeout::value_
long value_
Request timeout value specified.
Definition: listener.h:62