| Kea 3.0.2-git

isc::asiolink::IOAcceptor< ProtocolType, CallbackType > Class Template Reference

Base class for acceptor services in Kea. More...

`#include <io_acceptor.h>`

Inheritance diagram for isc::asiolink::IOAcceptor< ProtocolType, CallbackType >:
[legend]

## Public Member Functions
| IOAcceptor (const IOServicePtr &io_service)
| Constructor.
virtual | ~IOAcceptor ()
| Destructor.
template<typename EndpointType>
void | bind (const EndpointType &endpoint)
| Binds socket to an endpoint.
void | close () const
| Closes the acceptor.
virtual int | getNative () const
| Returns file descriptor of the underlying socket.
bool | isOpen () const
| Checks if the acceptor is open.
void | listen ()
| Starts listening new connections.
template<typename EndpointType>
void | open (const EndpointType &endpoint)
| Opens acceptor socket given the endpoint.
template<typename SettableSocketOption>
void | setOption (const SettableSocketOption &socket_option)
| Sets socket option.
virtual | ~IOSocket ()
| The destructor.
virtual int | getProtocol () const =0
| Return the transport protocol of the socket.

## Protected Member Functions
template<typename SocketType>
void | asyncAcceptInternal (const SocketType &socket, const CallbackType &callback)
| Asynchronously accept new connection.
| IOSocket ()
| The default constructor.

## Protected Attributes
boost::shared_ptr< typename ProtocolType::acceptor > | acceptor_
| Underlying ASIO acceptor implementation.
IOServicePtr | io_service_
| The IO service used to handle events.

## Additional Inherited Members
Public Types inherited from isc::asiolink::IOSocket
typedef boost::asio::socket_base::reuse_address | ReuseAddress
| Represents SO_REUSEADDR socket option.
static IOSocket & | getDummyUDPSocket ()
| Return a non-usable "dummy" UDP socket for testing.
static IOSocket & | getDummyTCPSocket ()
| Return a non-usable "dummy" TCP socket for testing.

## Detailed Description

template<typename ProtocolType, typename CallbackType>
class isc::asiolink::IOAcceptor< ProtocolType, CallbackType >

Base class for acceptor services in Kea.

This is a wrapper class for ASIO acceptor service. Classes implementing services for specific protocol types should derive from this class.

Acceptor is an IO object which accepts incoming connections into a socket object. This socket is then used for data transmission from the client to server and back. The acceptor is continued to be used to accept new connections while the accepted connection is active.

Template Parameters

  ProtocolType | ASIO protocol type, e.g. stream_protocol
  CallbackType | Callback function type which should have the following signature: `void(const boost::system::error_code&)`.

Definition at line 34 of file io_acceptor.h.

## Constructor & Destructor Documentation

## ◆ IOAcceptor()

template<typename ProtocolType, typename CallbackType>

isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::IOAcceptor | ( | const IOServicePtr & | io_service | ) |
| inline explicit

Constructor.

Parameters

  io_service | Reference to the IO service.

Definition at line 40 of file io_acceptor.h.

References acceptor_, and io_service_.

Referenced by isc::asiolink::TCPAcceptor< HttpAcceptorCallback >::TCPAcceptor().

## ◆ ~IOAcceptor()

template<typename ProtocolType, typename CallbackType>

virtual isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::~IOAcceptor | ( |  | ) |
| inline virtual

Destructor.

Definition at line 46 of file io_acceptor.h.

## Member Function Documentation

## ◆ asyncAcceptInternal()

template<typename ProtocolType, typename CallbackType>
template<typename SocketType>

void isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::asyncAcceptInternal | ( | const SocketType & | socket,
|  | const CallbackType & | callback )
| inline protected

Asynchronously accept new connection.

This method accepts new connection into the specified socket. When the new connection arrives or an error occurs the specified callback function is invoked.

Parameters

  socket | Socket into which connection should be accepted.
  callback | Callback function to be invoked when the new connection arrives.

Template Parameters

  SocketType | Socket type, e.g. UnixDomainSocket. It must implement `getASIOSocket` method.

Definition at line 117 of file io_acceptor.h.

References acceptor_.

Referenced by isc::asiolink::TCPAcceptor< HttpAcceptorCallback >::asyncAccept().

## ◆ bind()

template<typename ProtocolType, typename CallbackType>
template<typename EndpointType>

void isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::bind | ( | const EndpointType & | endpoint | ) |
| inline

Binds socket to an endpoint.

Parameters

  endpoint | Reference to the endpoint object defining local acceptor endpoint.

Template Parameters

  EndpointType | Endpoint type.

Definition at line 71 of file io_acceptor.h.

References acceptor_.

## ◆ close()

template<typename ProtocolType, typename CallbackType>

void isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::close | ( |  | ) | const
| inline

Closes the acceptor.

Definition at line 99 of file io_acceptor.h.

References acceptor_.

## ◆ getNative()

template<typename ProtocolType, typename CallbackType>

virtual int isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::getNative | ( |  | ) | const
| inline virtual

Returns file descriptor of the underlying socket.

Implements isc::asiolink::IOSocket.

Definition at line 49 of file io_acceptor.h.

References acceptor_.

## ◆ isOpen()

template<typename ProtocolType, typename CallbackType>

bool isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::isOpen | ( |  | ) | const
| inline

Checks if the acceptor is open.

Returns
  true if acceptor is open.

Definition at line 94 of file io_acceptor.h.

References acceptor_.

## ◆ listen()

template<typename ProtocolType, typename CallbackType>

void isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::listen | ( |  | ) |
| inline

Starts listening new connections.

Definition at line 87 of file io_acceptor.h.

References acceptor_.

## ◆ open()

template<typename ProtocolType, typename CallbackType>
template<typename EndpointType>

void isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::open | ( | const EndpointType & | endpoint | ) |
| inline

Opens acceptor socket given the endpoint.

Parameters

  endpoint | Reference to the endpoint object defining local acceptor endpoint.

Template Parameters

  EndpointType | Endpoint type.

Definition at line 60 of file io_acceptor.h.

References acceptor_.

## ◆ setOption()

template<typename ProtocolType, typename CallbackType>
template<typename SettableSocketOption>

void isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::setOption | ( | const SettableSocketOption & | socket_option | ) |
| inline

Sets socket option.

Parameters

  socket_option | Reference to the object encapsulating an option to be set for the socket.

Template Parameters

  SettableSocketOption | Type of the object encapsulating socket option being set.

Definition at line 82 of file io_acceptor.h.

References acceptor_.

## Member Data Documentation

## ◆ acceptor_

template<typename ProtocolType, typename CallbackType>

boost::shared_ptr<typename ProtocolType::acceptor> isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::acceptor_
| protected

Underlying ASIO acceptor implementation.

Definition at line 126 of file io_acceptor.h.

Referenced by IOAcceptor(), asyncAcceptInternal(), bind(), close(), getNative(), isOpen(), listen(), open(), and setOption().

## ◆ io_service_

template<typename ProtocolType, typename CallbackType>

IOServicePtr isc::asiolink::IOAcceptor< ProtocolType, CallbackType >::io_service_
| protected

The IO service used to handle events.

Definition at line 123 of file io_acceptor.h.

Referenced by IOAcceptor().

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

- io_acceptor.h