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);
125 virtual boost::asio::local::stream_protocol::socket&
getASIOSocket()
const;
130 boost::shared_ptr<UnixDomainSocketImpl> 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.
UnixDomainSocketError(const char *file, size_t line, const char *what)
std::function< void(const boost::system::error_code &, size_t)> Handler
Callback type used in calls to UnixDomainSocket::asyncSend and UnixDomainSocket::asyncReceive.
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.
std::function< void(const boost::system::error_code &)> ConnectHandler
Callback type used in call to UnixDomainSocket::asyncConnect.
UnixDomainSocket(const IOServicePtr &io_service)
Constructor.
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.
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.
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.