Kea 2.7.5
|
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. | |
typedef std::function< void(const boost::system::error_code &, size_t) | Handler) |
Callback type used in calls to UnixDomainSocket::asyncSend and UnixDomainSocket::asyncReceive. | |
Public Types inherited from isc::asiolink::IOSocket | |
typedef boost::asio::socket_base::reuse_address | ReuseAddress |
Represents SO_REUSEADDR socket option. | |
Public Member Functions | |
UnixDomainSocket (const IOServicePtr &io_service) | |
Constructor. | |
void | asyncConnect (const std::string &path, const ConnectHandler &handler) |
Asynchronously connects the socket to the specified endpoint. | |
void | asyncReceive (void *data, const size_t length, const Handler &handler) |
Asynchronously receives data over the socket. | |
void | asyncSend (const void *data, const size_t length, const Handler &handler) |
Asynchronously sends data over the socket. | |
void | cancel () |
Cancels scheduled asynchronous operations on the socket. | |
void | close () |
Closes the socket. | |
void | connect (const std::string &path) |
Connects the socket to the specified endpoint. | |
virtual boost::asio::local::stream_protocol::socket & | getASIOSocket () const |
Returns reference to the underlying ASIO socket. | |
virtual int | getNative () const |
Returns native socket representation. | |
virtual int | getProtocol () const |
Always returns 0. | |
size_t | receive (void *data, size_t length) |
Receives data from a socket. | |
void | shutdown () |
Disables read and write operations on the socket. | |
size_t | write (const void *data, size_t length) |
Writes specified amount of data to a socket. | |
Public Member Functions inherited from isc::asiolink::IOSocket | |
virtual | ~IOSocket () |
The destructor. | |
Additional Inherited Members | |
Static Public Member Functions inherited from isc::asiolink::IOSocket | |
static IOSocket & | getDummyUDPSocket () |
Return a non-usable "dummy" UDP socket for testing. | |
static IOSocket & | getDummyTCPSocket () |
Return a non-usable "dummy" TCP socket for testing. | |
Protected Member Functions inherited from isc::asiolink::IOSocket | |
IOSocket () | |
The default constructor. | |
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 286 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 314 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 348 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 332 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 359 of file unix_domain_socket.cc.
void isc::asiolink::UnixDomainSocket::close | ( | ) |
Closes the socket.
UnixDomainSocketError | if an error occurs during closure. |
Definition at line 364 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 305 of file unix_domain_socket.cc.
References isc_throw.
|
virtual |
Returns reference to the underlying ASIO socket.
Definition at line 369 of file unix_domain_socket.cc.
|
virtual |
Returns native socket representation.
Implements isc::asiolink::IOSocket.
Definition at line 291 of file unix_domain_socket.cc.
|
virtual |
Always returns 0.
Implements isc::asiolink::IOSocket.
Definition at line 300 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 338 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 354 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 319 of file unix_domain_socket.cc.
References isc_throw.