12namespace ph = std::placeholders;
19 const unsigned short server_port,
23 : io_service_(io_service), tls_context_(tls_context), acceptor_(),
24 endpoint_(), connections_(), idle_timeout_(idle_timeout.value_),
25 connection_filter_(connection_filter) {
38 << server_address <<
":" << server_port);
65 }
catch (
const boost::system::system_error& ex) {
68 "listening for incoming TCP clients: " << ex.
what());
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
A generic exception that is thrown when a function is not implemented.
The IOAddress class represents an IP addresses (version agnostic)
boost::asio::socket_base::reuse_address ReuseAddress
Represents SO_REUSEADDR socket option.
The TCPEndpoint class is a concrete derived class of IOEndpoint that represents an endpoint of a TCP ...
void stopAll()
Stops all connections and removes them from the pool.
void start(const TcpConnectionPtr &connection)
Start new connection.
A generic error raised by the TcpListener class.
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.
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 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.
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.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
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.
std::function< bool(const boost::asio::ip::tcp::endpoint &)> TcpConnectionFilterCallback
Type of the callback for filtering new connections by ip address.
asiolink::TLSAcceptor< TcpConnectionAcceptorCallback > TlsConnectionAcceptor
Type of the TLS acceptor used in this library.
boost::shared_ptr< TcpConnection > TcpConnectionPtr
Pointer to the TcpConnection.
asiolink::TCPAcceptor< TcpConnectionAcceptorCallback > TcpConnectionAcceptor
Type of the TCP acceptor used in this library.
std::function< void(const boost::system::error_code &)> TcpConnectionAcceptorCallback
Type of the callback for the TCP acceptor used in this library.
Defines the logger used by the top-level component of kea-lfc.