Kea  1.9.9-git
isc::asiolink::UnixDomainSocket Class Reference

Represents unix domain socket implemented in terms of boost asio. More...

#include <unix_domain_socket.h>

+ Inheritance diagram for isc::asiolink::UnixDomainSocket:

Public Types

typedef std::function< void(const boost::system::error_code &)> ConnectHandler
 Callback type used in call to UnixDomainSocket::asyncConnect. More...
 
typedef std::function< void(const boost::system::error_code &, size_t)> Handler
 Callback type used in calls to UnixDomainSocket::asyncSend and UnixDomainSocket::asyncReceive. More...
 

Public Member Functions

 UnixDomainSocket (IOService &io_service)
 Constructor. More...
 
void asyncConnect (const std::string &path, const ConnectHandler &handler)
 Asynchronously connects the socket to the specified endpoint. More...
 
void asyncReceive (void *data, const size_t length, const Handler &handler)
 Asynchronously receives data over the socket. More...
 
void asyncSend (const void *data, const size_t length, const Handler &handler)
 Asynchronously sends data over the socket. More...
 
void cancel ()
 Cancels scheduled asynchronous operations on the socket. More...
 
void close ()
 Closes the socket. More...
 
void connect (const std::string &path)
 Connects the socket to the specified endpoint. More...
 
virtual boost::asio::local::stream_protocol::socket & getASIOSocket () const
 Returns reference to the underlying ASIO socket. More...
 
virtual int getNative () const
 Returns native socket representation. More...
 
virtual int getProtocol () const
 Always returns 0. More...
 
size_t receive (void *data, size_t length)
 Receives data from a socket. More...
 
void shutdown ()
 Disables read and write operations on the socket. More...
 
size_t write (const void *data, size_t length)
 Writes specified amount of data to a socket. More...
 

Additional Inherited Members

Detailed Description

Represents unix domain socket implemented in terms of boost asio.

Definition at line 30 of file unix_domain_socket.h.

Member Typedef Documentation

typedef std::function<void(const boost::system::error_code&)> isc::asiolink::UnixDomainSocket::ConnectHandler

Callback type used in call to UnixDomainSocket::asyncConnect.

Definition at line 34 of file unix_domain_socket.h.

typedef std::function<void(const boost::system::error_code&, size_t)> isc::asiolink::UnixDomainSocket::Handler

Callback type used in calls to UnixDomainSocket::asyncSend and UnixDomainSocket::asyncReceive.

Definition at line 38 of file unix_domain_socket.h.

Constructor & Destructor Documentation

isc::asiolink::UnixDomainSocket::UnixDomainSocket ( IOService io_service)
explicit

Constructor.

Parameters
io_serviceReference to IOService to be used by this class.

Definition at line 283 of file unix_domain_socket.cc.

Member Function Documentation

void isc::asiolink::UnixDomainSocket::asyncConnect ( const std::string &  path,
const ConnectHandler handler 
)

Asynchronously connects the socket to the specified endpoint.

Always returns immediately.

Parameters
pathPath to the unix socket to which we should connect.
handlerCallback to be invoked when connection is established or a connection error is signalled.

Definition at line 311 of file unix_domain_socket.cc.

Referenced by isc::config::ClientConnectionImpl::start().

void isc::asiolink::UnixDomainSocket::asyncReceive ( void *  data,
const size_t  length,
const Handler handler 
)

Asynchronously receives data over the socket.

Always returns immediately.

Parameters
[out]dataPointer to a location into which the read data should be stored.
lengthLength of the buffer.
handlerCallback to be invoked when data have been received or an error is signalled.

Definition at line 345 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocket::asyncSend ( const void *  data,
const size_t  length,
const Handler handler 
)

Asynchronously sends data over the socket.

Always returns immediately.

Parameters
dataPointer to data to be sent.
lengthNumber of bytes to be sent.
handlerCallback to be invoked when data have been sent or sending error is signalled.

Definition at line 329 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocket::cancel ( )

Cancels scheduled asynchronous operations on the socket.

Exceptions
UnixDomainSocketErrorif an error occurs during cancel operation.

Definition at line 356 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocket::close ( )

Closes the socket.

Exceptions
UnixDomainSocketErrorif an error occurs during closure.

Definition at line 361 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocket::connect ( const std::string &  path)

Connects the socket to the specified endpoint.

Parameters
pathPath to the unix socket to which we should connect.
Exceptions
UnixDomainSocketErrorif error occurs.

Definition at line 302 of file unix_domain_socket.cc.

References isc_throw.

boost::asio::local::stream_protocol::socket & isc::asiolink::UnixDomainSocket::getASIOSocket ( ) const
virtual

Returns reference to the underlying ASIO socket.

Returns
Reference to underlying ASIO socket.

Definition at line 366 of file unix_domain_socket.cc.

int isc::asiolink::UnixDomainSocket::getNative ( ) const
virtual

Returns native socket representation.

Implements isc::asiolink::IOSocket.

Definition at line 288 of file unix_domain_socket.cc.

int isc::asiolink::UnixDomainSocket::getProtocol ( ) const
virtual

Always returns 0.

Implements isc::asiolink::IOSocket.

Definition at line 297 of file unix_domain_socket.cc.

size_t isc::asiolink::UnixDomainSocket::receive ( void *  data,
size_t  length 
)

Receives data from a socket.

Parameters
[out]dataPointer to a location into which the read data should be stored.
lengthLength of the buffer.
Returns
Number of bytes read.
Exceptions
UnixDomainSocketErrorif error occurs.

Definition at line 335 of file unix_domain_socket.cc.

References isc_throw.

void isc::asiolink::UnixDomainSocket::shutdown ( )

Disables read and write operations on the socket.

Exceptions
UnixDomainSocketErrorif an error occurs during shutdown.

Definition at line 351 of file unix_domain_socket.cc.

size_t isc::asiolink::UnixDomainSocket::write ( const void *  data,
size_t  length 
)

Writes specified amount of data to a socket.

Parameters
dataPointer to data to be written.
lengthNumber of bytes to be written.
Returns
Number of bytes written.
Exceptions
UnixDomainSocketErrorif error occurs.

Definition at line 316 of file unix_domain_socket.cc.

References isc_throw.


The documentation for this class was generated from the following files: