14#include <boost/scoped_ptr.hpp>
61 const unsigned short server_port,
105 size_t& total_connections) {
This is a base class for exceptions thrown from the DNS library module.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
The IOAddress class represents an IP addresses (version agnostic)
The TCPEndpoint class is a concrete derived class of IOEndpoint that represents an endpoint of a TCP ...
Pool of active TCP connections.
size_t usedByRemoteIp(const asiolink::IOAddress &remote_ip, size_t &total_connections)
Returns the number of connections using a given remote IP address.
A generic error raised by the TcpListener class.
TcpListenerError(const char *file, size_t line, const char *what)
Implements a class that listens for, accepts, and manages TCP connections.
asiolink::IOServicePtr io_service_
Pointer to the IO service.
TcpListener(const asiolink::IOServicePtr &io_service, const asiolink::IOAddress &server_address, const unsigned short server_port, const asiolink::TlsContextPtr &tls_context, const IdleTimeout &idle_timeout, const TcpConnectionFilterCallback &connection_filter=0)
Constructor.
asiolink::TlsContextPtr tls_context_
TLS context.
TcpConnectionPool connections_
Pool of active connections.
void start()
Starts accepting new connections.
const asiolink::TCPEndpoint & getEndpoint() const
Returns reference to the current listener endpoint.
long getIdleTimeout() const
Returns the idle timeout (in milliseconds).
long idle_timeout_
Timeout after which idle connection is closed by the server.
TcpConnectionAcceptorPtr acceptor_
Acceptor instance.
uint16_t getLocalPort() const
Returns local port on which server is listening.
virtual ~TcpListener()
Virtual destructor.
asiolink::IOAddress getLocalAddress() const
Returns local address on which server is listening.
void accept()
Creates TcpConnection instance and adds it to the pool of active connections.
virtual TcpConnectionPtr createConnection(const TcpConnectionAcceptorCallback &acceptor_callback, const TcpConnectionFilterCallback &connection_filter)
Creates an instance of the TcpConnection.
size_t usedByRemoteIp(const asiolink::IOAddress &remote_ip, size_t &total_connections)
Returns the number of connections using a given remote IP address.
boost::scoped_ptr< asiolink::TCPEndpoint > endpoint_
Pointer to the endpoint representing IP address and port on which the service is running.
void acceptHandler(const boost::system::error_code &ec)
Callback invoked when the new connection is accepted.
TcpConnectionFilterCallback connection_filter_
Callback invoked during acceptance which may reject connections.
void stop()
Stops all active connections and shuts down the service.
boost::shared_ptr< TlsContext > TlsContextPtr
The type of shared pointers to TlsContext objects.
boost::shared_ptr< IOService > IOServicePtr
Defines a smart pointer to an IOService instance.
boost::shared_ptr< TcpConnectionAcceptor > TcpConnectionAcceptorPtr
Type of shared pointer to TCP acceptors.
std::function< bool(const boost::asio::ip::tcp::endpoint &) TcpConnectionFilterCallback)
Type of the callback for filtering new connections by ip address.
boost::shared_ptr< TcpConnection > TcpConnectionPtr
Pointer to the TcpConnection.
std::function< void(const boost::system::error_code &) TcpConnectionAcceptorCallback)
Type of the callback for the TCP acceptor used in this library.
boost::shared_ptr< TcpListener > TcpListenerPtr
Pointer to a TcpListener.
Defines the logger used by the top-level component of kea-lfc.
long value_
Connection idle timeout value specified.
IdleTimeout(long value)
Constructor.