Kea 2.5.9
isc::asiolink::UnixDomainSocket Class Reference

Represents unix domain socket implemented in terms of boost asio. More...

#include <unix_domain_socket.h>

+ Inheritance diagram for isc::asiolink::UnixDomainSocket:

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 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.
 

Additional Inherited Members

Detailed Description

Represents unix domain socket implemented in terms of boost asio.

Definition at line 30 of file unix_domain_socket.h.

Member Typedef Documentation

◆ ConnectHandler

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.

◆ Handler

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.

Constructor & Destructor Documentation

◆ UnixDomainSocket()

isc::asiolink::UnixDomainSocket::UnixDomainSocket ( const IOServicePtr io_service)
explicit

Constructor.

Parameters
io_serviceReference to IOService to be used by this class.

Definition at line 286 of file unix_domain_socket.cc.

Member Function Documentation

◆ asyncConnect()

void isc::asiolink::UnixDomainSocket::asyncConnect ( const std::string &  path,
const ConnectHandler handler 
)

Asynchronously connects the socket to the specified endpoint.

Always returns immediately.

Parameters
pathPath to the unix socket to which we should connect.
handlerCallback 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().

◆ asyncReceive()

void isc::asiolink::UnixDomainSocket::asyncReceive ( void *  data,
const size_t  length,
const Handler handler 
)

Asynchronously receives data over the socket.

Always returns immediately.

Parameters
[out]dataPointer to a location into which the read data should be stored.
lengthLength of the buffer.
handlerCallback to be invoked when data have been received or an error is signalled.

Definition at line 348 of file unix_domain_socket.cc.

◆ asyncSend()

void isc::asiolink::UnixDomainSocket::asyncSend ( const void *  data,
const size_t  length,
const Handler handler 
)

Asynchronously sends data over the socket.

Always returns immediately.

Parameters
dataPointer to data to be sent.
lengthNumber of bytes to be sent.
handlerCallback to be invoked when data have been sent or sending error is signalled.

Definition at line 332 of file unix_domain_socket.cc.

◆ cancel()

void isc::asiolink::UnixDomainSocket::cancel ( )

Cancels scheduled asynchronous operations on the socket.

Exceptions
UnixDomainSocketErrorif an error occurs during cancel operation.

Definition at line 359 of file unix_domain_socket.cc.

◆ close()

void isc::asiolink::UnixDomainSocket::close ( )

Closes the socket.

Exceptions
UnixDomainSocketErrorif an error occurs during closure.

Definition at line 364 of file unix_domain_socket.cc.

◆ connect()

void isc::asiolink::UnixDomainSocket::connect ( const std::string &  path)

Connects the socket to the specified endpoint.

Parameters
pathPath to the unix socket to which we should connect.
Exceptions
UnixDomainSocketErrorif error occurs.

Definition at line 305 of file unix_domain_socket.cc.

References isc_throw.

◆ getASIOSocket()

boost::asio::local::stream_protocol::socket & isc::asiolink::UnixDomainSocket::getASIOSocket ( ) const
virtual

Returns reference to the underlying ASIO socket.

Returns
Reference to underlying ASIO socket.

Definition at line 369 of file unix_domain_socket.cc.

◆ getNative()

int isc::asiolink::UnixDomainSocket::getNative ( ) const
virtual

Returns native socket representation.

Implements isc::asiolink::IOSocket.

Definition at line 291 of file unix_domain_socket.cc.

◆ getProtocol()

int isc::asiolink::UnixDomainSocket::getProtocol ( ) const
virtual

Always returns 0.

Implements isc::asiolink::IOSocket.

Definition at line 300 of file unix_domain_socket.cc.

◆ receive()

size_t isc::asiolink::UnixDomainSocket::receive ( void *  data,
size_t  length 
)

Receives data from a socket.

Parameters
[out]dataPointer to a location into which the read data should be stored.
lengthLength of the buffer.
Returns
Number of bytes read.
Exceptions
UnixDomainSocketErrorif error occurs.

Definition at line 338 of file unix_domain_socket.cc.

References isc_throw.

◆ shutdown()

void isc::asiolink::UnixDomainSocket::shutdown ( )

Disables read and write operations on the socket.

Exceptions
UnixDomainSocketErrorif an error occurs during shutdown.

Definition at line 354 of file unix_domain_socket.cc.

◆ write()

size_t isc::asiolink::UnixDomainSocket::write ( const void *  data,
size_t  length 
)

Writes specified amount of data to a socket.

Parameters
dataPointer to data to be written.
lengthNumber of bytes to be written.
Returns
Number of bytes written.
Exceptions
UnixDomainSocketErrorif error occurs.

Definition at line 319 of file unix_domain_socket.cc.

References isc_throw.


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