Kea 2.7.6
isc::asiolink::UnixDomainSocketImpl Class Reference

Implementation of the unix domain socket. More...

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

Public Member Functions

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

Public Attributes

IOServicePtr io_service_
 The IO service used to handle events.
 
stream_protocol::socket socket_
 Instance of the boost asio unix domain socket.
 

Detailed Description

Implementation of the unix domain socket.

Definition at line 22 of file unix_domain_socket.cc.

Constructor & Destructor Documentation

◆ UnixDomainSocketImpl()

isc::asiolink::UnixDomainSocketImpl::UnixDomainSocketImpl ( const IOServicePtr & 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.

◆ ~UnixDomainSocketImpl()

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

Destructor.

Closes the socket.

Definition at line 35 of file unix_domain_socket.cc.

References close().

+ Here is the call graph for this function:

Member Function Documentation

◆ asyncConnect()

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 170 of file unix_domain_socket.cc.

References connectHandler(), and socket_.

+ Here is the call graph for this function:

◆ asyncReceive()

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 227 of file unix_domain_socket.cc.

References doReceive().

+ Here is the call graph for this function:

◆ asyncSend()

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 194 of file unix_domain_socket.cc.

References doSend().

+ Here is the call graph for this function:

◆ cancel()

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

Cancels asynchronous operations on the socket.

Definition at line 269 of file unix_domain_socket.cc.

References isc_throw, and socket_.

◆ close()

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

Closes the socket.

Definition at line 278 of file unix_domain_socket.cc.

References isc_throw, and socket_.

Referenced by ~UnixDomainSocketImpl().

◆ connectHandler()

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 179 of file unix_domain_socket.cc.

Referenced by asyncConnect().

◆ doReceive()

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 233 of file unix_domain_socket.cc.

References receiveHandler(), and socket_.

Referenced by asyncReceive(), and receiveHandler().

+ Here is the call graph for this function:

◆ doSend()

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 200 of file unix_domain_socket.cc.

References sendHandler(), and socket_.

Referenced by asyncSend(), and sendHandler().

+ Here is the call graph for this function:

◆ receiveHandler()

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 242 of file unix_domain_socket.cc.

References doReceive().

Referenced by doReceive().

+ Here is the call graph for this function:

◆ sendHandler()

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 209 of file unix_domain_socket.cc.

References doSend().

Referenced by doSend().

+ Here is the call graph for this function:

◆ shutdown()

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

Disables read and write operations on the socket.

Definition at line 260 of file unix_domain_socket.cc.

References isc_throw, and socket_.

Member Data Documentation

◆ io_service_

IOServicePtr isc::asiolink::UnixDomainSocketImpl::io_service_

The IO service used to handle events.

Definition at line 163 of file unix_domain_socket.cc.

◆ socket_

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

Instance of the boost asio unix domain socket.

Definition at line 166 of file unix_domain_socket.cc.

Referenced by asyncConnect(), cancel(), close(), doReceive(), doSend(), and shutdown().


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