Kea
1.9.9-git
|
Implementation of the unix domain socket. More...
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... | |
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 |
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 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.
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 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.
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 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 | ( | ) |
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 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.
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 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.
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 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.
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 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.
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 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.
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.