15#include <boost/shared_ptr.hpp>
94 typedef std::function<void(
const boost::system::error_code&,
118 typedef std::function<bool(
const boost::system::error_code&,
132 typedef std::function<bool(
const boost::system::error_code&,
155 bool multi_threading_enabled,
156 size_t thread_pool_size = 0,
157 bool defer_thread_start =
false);
249 const bool persistent,
342 boost::shared_ptr<TcpClientImpl> impl_;
Exception(const char *file, size_t line, const char *what)
Constructor for a given type for exceptions with file name and file line number.
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)
TcpClientError(const char *file, size_t line, const char *what)
std::function< int(const WireDataPtr &, std::string &)> CompleteCheck
Completion check type.
void closeIfOutOfBand(int socket_fd)
Closes a connection if it has an out-of-band socket event.
void start()
Starts running the client's thread pool, if multi-threaded.
uint16_t getThreadCount() const
Fetches the number of threads in the pool.
std::function< void(const boost::system::error_code &, const WireDataPtr &, const std::string &)> RequestHandler
Callback type used in call to TcpClient::asyncSendRequest.
void stop()
Halts client-side IO activity.
bool isPaused()
Indicates if the thread pool is paused.
uint16_t getThreadPoolSize() const
Fetches the maximum size of the thread pool.
void checkPermissions()
Check if the current thread can perform thread pool state transition.
void asyncSendRequest(const asiolink::IOAddress &address, const uint16_t port, const asiolink::TlsContextPtr &tls_context, const WireDataPtr &request, const WireDataPtr &response, const bool persistent, const CompleteCheck &complete_check, const RequestHandler &request_callback, const RequestTimeout &request_timeout=RequestTimeout(10000), const ConnectHandler &connect_callback=ConnectHandler(), const HandshakeHandler &handshake_callback=HandshakeHandler(), const CloseHandler &close_callback=CloseHandler())
Queues new asynchronous TCP request for a given address.
bool isRunning()
Indicates if the thread pool is running.
std::function< bool(const boost::system::error_code &, const int)> ConnectHandler
Optional handler invoked when client connects to the server.
void pause()
Pauses the client's thread pool.
bool isStopped()
Indicates if the thread pool is stopped.
TcpClient(const asiolink::IOServicePtr &io_service, bool multi_threading_enabled, size_t thread_pool_size=0, bool defer_thread_start=false)
Constructor.
std::function< bool(const boost::system::error_code &, const int)> HandshakeHandler
Optional handler invoked when client performs the TLS handshake with the server.
void resume()
Resumes running the client's thread pool.
const asiolink::IOServicePtr getThreadIOService() const
Fetches a pointer to the internal IOService used to drive the thread-pool in multi-threaded mode.
std::function< void(const int)> CloseHandler
Optional handler invoked when client closes the connection to the server.
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< WireData > WireDataPtr
boost::shared_ptr< TcpClient > TcpClientPtr
Defines a pointer to an TcpClient instance.
Defines the logger used by the top-level component of kea-lfc.
TCP request/response timeout value.
RequestTimeout(long value)
Constructor.
long value_
Timeout value specified.