Kea 2.7.6
|
Implementation of the unix domain socket. More...
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. | |
Implementation of the unix domain socket.
Definition at line 22 of file unix_domain_socket.cc.
|
inline |
Constructor.
io_service | IO service to be used by the socket class. |
Definition at line 28 of file unix_domain_socket.cc.
|
inline |
Destructor.
Closes the socket.
Definition at line 35 of file unix_domain_socket.cc.
References close().
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.
endpoint | Reference to an endpoint to connect to. |
handler | User 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_.
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.
data | Pointer to a buffer into which the data should be read. |
length | Length of the buffer. |
handler | User 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().
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.
data | Pointer to data to be sent. |
length | Number of bytes to be sent. |
handler | Callback 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().
void isc::asiolink::UnixDomainSocketImpl::cancel | ( | ) |
Cancels asynchronous operations on the socket.
Definition at line 269 of file unix_domain_socket.cc.
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().
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.
remote_handler | User supplied callback. |
ec | Error code returned as a result of connection. |
Definition at line 179 of file unix_domain_socket.cc.
Referenced by asyncConnect().
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.
buffer | A buffer into which the data should be received. |
handler | User 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().
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.
buffer | Buffers holding the data to be sent. |
handler | User 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().
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.
remote_handler | User supplied callback. |
buffer | Buffer into which the data are received. |
ec | Error code returned as a result of asynchronous receive. |
length | Size of the received data. |
Definition at line 242 of file unix_domain_socket.cc.
References doReceive().
Referenced by doReceive().
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.
remote_handler | User supplied callback. |
buffer | Buffers holding the data to be sent. |
ec | Error code returned as a result of sending the data. |
length | Length of the data sent. |
Definition at line 209 of file unix_domain_socket.cc.
References doSend().
Referenced by doSend().
void isc::asiolink::UnixDomainSocketImpl::shutdown | ( | ) |
Disables read and write operations on the socket.
Definition at line 260 of file unix_domain_socket.cc.
IOServicePtr isc::asiolink::UnixDomainSocketImpl::io_service_ |
The IO service used to handle events.
Definition at line 163 of file unix_domain_socket.cc.
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().