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