7 #ifndef UNIX_DOMAIN_SOCKET_H
8 #define UNIX_DOMAIN_SOCKET_H
12 #include <boost/shared_ptr.hpp>
26 class UnixDomainSocketImpl;
34 typedef std::function<void(const boost::system::error_code&)>
ConnectHandler;
38 typedef std::function<void(const boost::system::error_code&, size_t)>
Handler;
57 void connect(
const std::string& path);
66 void asyncConnect(
const std::string& path,
const ConnectHandler& handler);
75 size_t write(
const void* data,
size_t length);
85 void asyncSend(
const void* data,
const size_t length,
const Handler& handler);
95 size_t receive(
void* data,
size_t length);
105 void asyncReceive(
void* data,
const size_t length,
const Handler& handler);
125 virtual boost::asio::local::stream_protocol::socket&
getASIOSocket()
const;
130 boost::shared_ptr<UnixDomainSocketImpl> impl_;
137 #endif // UNIX_DOMAIN_SOCKET_H
void cancel()
Cancels scheduled asynchronous operations on the socket.
void shutdown()
Disables read and write operations on the socket.
size_t write(const void *data, size_t length)
Writes specified amount of data to a socket.
void close()
Closes the socket.
std::function< void(const boost::system::error_code &)> ConnectHandler
Callback type used in call to UnixDomainSocket::asyncConnect.
std::function< void(const boost::system::error_code &, size_t)> Handler
Callback type used in calls to UnixDomainSocket::asyncSend and UnixDomainSocket::asyncReceive.
The IOService class is a wrapper for the ASIO io_service class.
virtual int getProtocol() const
Always returns 0.
void asyncSend(const void *data, const size_t length, const Handler &handler)
Asynchronously sends data over the socket.
Represents unix domain socket implemented in terms of boost asio.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
UnixDomainSocket(IOService &io_service)
Constructor.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-dhcp-ddns.
The IOSocket class is an abstract base class to represent various types of network sockets...
void asyncConnect(const std::string &path, const ConnectHandler &handler)
Asynchronously connects the socket to the specified endpoint.
Exception thrown upon socket error.
size_t receive(void *data, size_t length)
Receives data from a socket.
A wrapper interface for the ASIO library.
UnixDomainSocketError(const char *file, size_t line, const char *what)
void connect(const std::string &path)
Connects the socket to the specified endpoint.
virtual int getNative() const
Returns native socket representation.
void asyncReceive(void *data, const size_t length, const Handler &handler)
Asynchronously receives data over the socket.
virtual boost::asio::local::stream_protocol::socket & getASIOSocket() const
Returns reference to the underlying ASIO socket.