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

Implementation of the unix domain socket. More...

+ Inheritance diagram for isc::asiolink::UnixDomainSocketImpl:

Public Member Functions

 UnixDomainSocketImpl (IOService &io_service)
 Constructor. More...
 
 ~UnixDomainSocketImpl ()
 Destructor. More...
 
void asyncConnect (const stream_protocol::endpoint &endpoint, const UnixDomainSocket::ConnectHandler &handler)
 Asynchronously connects to an endpoint. More...
 
void asyncReceive (void *data, const size_t length, const UnixDomainSocket::Handler &handler)
 Asynchronously receive data over the socket. More...
 
void asyncSend (const void *data, const size_t length, const UnixDomainSocket::Handler &handler)
 Asynchronously sends data over the socket. More...
 
void cancel ()
 Cancels asynchronous operations on the socket. More...
 
void close ()
 Closes the socket. More...
 
void connectHandler (const UnixDomainSocket::ConnectHandler &remote_handler, const boost::system::error_code &ec)
 Local handler invoked as a result of asynchronous connection. More...
 
void doReceive (const boost::asio::mutable_buffers_1 &buffer, const UnixDomainSocket::Handler &handler)
 Asynchronously receives the data over the socket. More...
 
void doSend (const boost::asio::const_buffers_1 &buffer, const UnixDomainSocket::Handler &handler)
 Asynchronously sends the data over the socket. More...
 
void receiveHandler (const UnixDomainSocket::Handler &remote_handler, const boost::asio::mutable_buffers_1 &buffer, const boost::system::error_code &ec, size_t length)
 Local handler invoked as a result of asynchronous receive. More...
 
void sendHandler (const UnixDomainSocket::Handler &remote_handler, const boost::asio::const_buffers_1 &buffer, const boost::system::error_code &ec, size_t length)
 Local handler invoked as a result of asynchronous send. More...
 
void shutdown ()
 Disables read and write operations on the socket. More...
 

Public Attributes

stream_protocol::socket socket_
 Instance of the boost asio unix domain socket. More...
 

Detailed Description

Implementation of the unix domain socket.

Definition at line 22 of file unix_domain_socket.cc.

Constructor & Destructor Documentation

isc::asiolink::UnixDomainSocketImpl::UnixDomainSocketImpl ( IOService io_service)
inline

Constructor.

Parameters
io_serviceIO service to be used by the socket class.

Definition at line 28 of file unix_domain_socket.cc.

isc::asiolink::UnixDomainSocketImpl::~UnixDomainSocketImpl ( )
inline

Destructor.

Closes the socket.

Definition at line 35 of file unix_domain_socket.cc.

Member Function Documentation

void isc::asiolink::UnixDomainSocketImpl::asyncConnect ( const stream_protocol::endpoint &  endpoint,
const UnixDomainSocket::ConnectHandler handler 
)

Asynchronously connects to an endpoint.

This method schedules asynchronous connect and installs the UnixDomainSocketImpl::connectHandler as a callback.

Parameters
endpointReference to an endpoint to connect to.
handlerUser supplied handler to be invoked when the connection is established or when error is signalled.

Definition at line 167 of file unix_domain_socket.cc.

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

Asynchronously receive data over the socket.

This method schedules asynchronous receive and installs the UnixDomainSocketImpl::receiveHandler is a callback.

Parameters
dataPointer to a buffer into which the data should be read.
lengthLength of the buffer.
handlerUser supplied callback invoked when data have been received or an error is signalled.

Definition at line 224 of file unix_domain_socket.cc.

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

Asynchronously sends data over the socket.

This method schedules an asynchronous send and installs the UnixDomainSocketImpl::sendHandler as a callback.

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

Definition at line 191 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocketImpl::cancel ( )

Cancels asynchronous operations on the socket.

Definition at line 266 of file unix_domain_socket.cc.

References isc_throw.

void isc::asiolink::UnixDomainSocketImpl::close ( )

Closes the socket.

Definition at line 275 of file unix_domain_socket.cc.

References isc_throw.

void isc::asiolink::UnixDomainSocketImpl::connectHandler ( const UnixDomainSocket::ConnectHandler remote_handler,
const boost::system::error_code &  ec 
)

Local handler invoked as a result of asynchronous connection.

This is a wrapper around the user supplied callback. It ignores EINPROGRESS errors which are observed on some operating systems as a result of trying to connect asynchronously. This error code doesn't necessarily indicate a problem and the subsequent attempts to read and write to the socket will succeed. Therefore, the handler simply overrides this error code with success status. The user supplied handler doesn't need to deal with the EINPROGRESS error codes.

Parameters
remote_handlerUser supplied callback.
ecError code returned as a result of connection.

Definition at line 176 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocketImpl::doReceive ( const boost::asio::mutable_buffers_1 &  buffer,
const UnixDomainSocket::Handler handler 
)

Asynchronously receives the data over the socket.

This method is called asyncReceive and receiveHandler when EWOULDBLOCK or EAGAIN is returned.

Parameters
bufferA buffer into which the data should be received.
handlerUser supplied callback invoked when data have been received on an error is signalled.

Definition at line 230 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocketImpl::doSend ( const boost::asio::const_buffers_1 &  buffer,
const UnixDomainSocket::Handler handler 
)

Asynchronously sends the data over the socket.

This method is called by the asyncSend and the sendHandler if the asynchronous send has to be repeated as a result of receiving EAGAIN or EWOULDBLOCK.

Parameters
bufferBuffers holding the data to be sent.
handlerUser supplied callback to be invoked when data have been sent or sending error is signalled.

Definition at line 197 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocketImpl::receiveHandler ( const UnixDomainSocket::Handler remote_handler,
const boost::asio::mutable_buffers_1 &  buffer,
const boost::system::error_code &  ec,
size_t  length 
)

Local handler invoked as a result of asynchronous receive.

This handler is invoked as a result of asynchronous receive. It is a wrapper callback around the user supplied callback. It handles EWOULDBLOCK and EAGAIN by retrying to asynchronously receive the data. These errors are often returned on some operating systems, even though one would expect that asynchronous operation would not return such errors. Because these errors are handled by the wrapper callback, the user supplied callback never receives these errors.

Parameters
remote_handlerUser supplied callback.
bufferBuffer into which the data are received.
ecError code returned as a result of asynchronous receive.
lengthSize of the received data.

Definition at line 239 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocketImpl::sendHandler ( const UnixDomainSocket::Handler remote_handler,
const boost::asio::const_buffers_1 &  buffer,
const boost::system::error_code &  ec,
size_t  length 
)

Local handler invoked as a result of asynchronous send.

This handler is invoked as a result of asynchronous send. It is a wrapper callback around the user supplied callback. It handles EWOULDBLOCK and EAGAIN errors by retrying an asynchronous send. These errors are often returned on some operating systems, even though one would expect that asynchronous operation would not return such errors. Because these errors are handled by the wrapper callback, the user supplied callback never receives these errors.

Parameters
remote_handlerUser supplied callback.
bufferBuffers holding the data to be sent.
ecError code returned as a result of sending the data.
lengthLength of the data sent.

Definition at line 206 of file unix_domain_socket.cc.

void isc::asiolink::UnixDomainSocketImpl::shutdown ( )

Disables read and write operations on the socket.

Definition at line 257 of file unix_domain_socket.cc.

References isc_throw.

Member Data Documentation

stream_protocol::socket isc::asiolink::UnixDomainSocketImpl::socket_

Instance of the boost asio unix domain socket.

Definition at line 163 of file unix_domain_socket.cc.


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