Kea
1.9.9-git
|
Represents unix domain socket implemented in terms of boost asio. More...
#include <unix_domain_socket.h>
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 Types inherited from isc::asiolink::IOSocket | |
typedef boost::asio::socket_base::reuse_address | ReuseAddress |
Represents SO_REUSEADDR socket option. 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... | |
Public Member Functions inherited from isc::asiolink::IOSocket | |
virtual | ~IOSocket () |
The destructor. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from isc::asiolink::IOSocket | |
static IOSocket & | getDummyTCPSocket () |
Return a non-usable "dummy" TCP socket for testing. More... | |
static IOSocket & | getDummyUDPSocket () |
Return a non-usable "dummy" UDP socket for testing. More... | |
Protected Member Functions inherited from isc::asiolink::IOSocket | |
IOSocket () | |
The default constructor. More... | |
Represents unix domain socket implemented in terms of boost asio.
Definition at line 30 of file unix_domain_socket.h.
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.
|
explicit |
Constructor.
io_service | Reference to IOService to be used by this class. |
Definition at line 283 of file unix_domain_socket.cc.
void isc::asiolink::UnixDomainSocket::asyncConnect | ( | const std::string & | path, |
const ConnectHandler & | handler | ||
) |
Asynchronously connects the socket to the specified endpoint.
Always returns immediately.
path | Path to the unix socket to which we should connect. |
handler | Callback 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.
[out] | data | Pointer to a location into which the read data should be stored. |
length | Length of the buffer. | |
handler | Callback 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.
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 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.
UnixDomainSocketError | if an error occurs during cancel operation. |
Definition at line 356 of file unix_domain_socket.cc.
void isc::asiolink::UnixDomainSocket::close | ( | ) |
Closes the socket.
UnixDomainSocketError | if 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.
path | Path to the unix socket to which we should connect. |
UnixDomainSocketError | if error occurs. |
Definition at line 302 of file unix_domain_socket.cc.
References isc_throw.
|
virtual |
Returns reference to the underlying ASIO socket.
Definition at line 366 of file unix_domain_socket.cc.
|
virtual |
Returns native socket representation.
Implements isc::asiolink::IOSocket.
Definition at line 288 of file unix_domain_socket.cc.
|
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.
[out] | data | Pointer to a location into which the read data should be stored. |
length | Length of the buffer. |
UnixDomainSocketError | if 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.
UnixDomainSocketError | if 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.
data | Pointer to data to be written. |
length | Number of bytes to be written. |
UnixDomainSocketError | if error occurs. |
Definition at line 316 of file unix_domain_socket.cc.
References isc_throw.