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>
14 #include <boost/shared_ptr.hpp>
15 #include <stdint.h>
16 
17 namespace isc {
18 namespace http {
19 
21 class HttpListenerError : public Exception {
22 public:
23  HttpListenerError(const char* file, size_t line, const char* what) :
24  isc::Exception(file, line, what) { };
25 };
26 
28 class HttpListenerImpl;
29 
51 class HttpListener {
52 public:
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 
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 
111 
113  uint16_t getLocalPort() const;
114 
124  void start();
125 
127  void stop();
128 
129 private:
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::http::HttpListener::IdleTimeout::IdleTimeout
IdleTimeout(long value)
Constructor.
Definition: listener.h:70
isc::http::HttpListener::start
void start()
Starts accepting new connections.
Definition: listener.cc:227
io_address.h
isc::http::ConstHttpListenerPtr
boost::shared_ptr< const HttpListener > ConstHttpListenerPtr
Pointer to the const HttpListener.
Definition: listener.h:140
isc::http::HttpListener::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.
Definition: listener.cc:201
isc::http::HttpListener::stop
void stop()
Stops all active connections and shuts down the service.
Definition: listener.cc:232
io_service.h
isc::http::HttpListenerError
A generic error raised by the HttpListener class.
Definition: listener.h:21
isc::Exception
This is a base class for exceptions thrown from the DNS library module.
Definition: exceptions/exceptions.h:23
isc
Defines the logger used by the top-level component of kea-dhcp-ddns.
Definition: agent_parser.cc:144
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::http::HttpListener::getLocalAddress
asiolink::IOAddress getLocalAddress() const
Returns local address on which server is listening.
Definition: listener.cc:217
isc::http::HttpListenerError::HttpListenerError
HttpListenerError(const char *file, size_t line, const char *what)
Definition: listener.h:23
response_creator_factory.h
isc::http::HttpListener::getLocalPort
uint16_t getLocalPort() const
Returns local port on which server is listening.
Definition: listener.cc:222
isc::http::HttpListener
HTTP listener.
Definition: listener.h:51
isc::http::HttpResponseCreatorFactoryPtr
boost::shared_ptr< HttpResponseCreatorFactory > HttpResponseCreatorFactoryPtr
Pointer to the HttpResponseCreatorFactory.
Definition: response_creator_factory.h:54
isc::http::HttpListener::RequestTimeout
HTTP request timeout value.
Definition: listener.h:55
isc::http::HttpListener::IdleTimeout
Idle connection timeout.
Definition: listener.h:66
exceptions.h
isc::http::HttpListener::RequestTimeout::value_
long value_
Request timeout value specified.
Definition: listener.h:62
isc::http::HttpListener::IdleTimeout::value_
long value_
Connection idle timeout value specified.
Definition: listener.h:73
isc::http::HttpListener::RequestTimeout::RequestTimeout
RequestTimeout(long value)
Constructor.
Definition: listener.h:59
isc::http::HttpListenerPtr
boost::shared_ptr< HttpListener > HttpListenerPtr
Pointer to the HttpListener.
Definition: listener.h:137
isc::http::HttpListener::~HttpListener
~HttpListener()
Destructor.
Definition: listener.cc:212