![]() |
Kea 3.1.0
|
Base class for acceptor services in Kea. More...
#include <io_acceptor.h>
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 | |
![]() | |
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. | |
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.
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.
|
inlineexplicit |
Constructor.
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().
|
inlinevirtual |
Destructor.
Definition at line 46 of file io_acceptor.h.
|
inlineprotected |
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.
socket | Socket into which connection should be accepted. |
callback | Callback function to be invoked when the new connection arrives. |
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().
|
inline |
Binds socket to an endpoint.
endpoint | Reference to the endpoint object defining local acceptor endpoint. |
EndpointType | Endpoint type. |
Definition at line 71 of file io_acceptor.h.
References acceptor_.
|
inline |
|
inlinevirtual |
Returns file descriptor of the underlying socket.
Implements isc::asiolink::IOSocket.
Definition at line 49 of file io_acceptor.h.
References acceptor_.
|
inline |
Checks if the acceptor is open.
Definition at line 94 of file io_acceptor.h.
References acceptor_.
|
inline |
Starts listening new connections.
Definition at line 87 of file io_acceptor.h.
References acceptor_.
|
inline |
Opens acceptor socket given the endpoint.
endpoint | Reference to the endpoint object defining local acceptor endpoint. |
EndpointType | Endpoint type. |
Definition at line 60 of file io_acceptor.h.
References acceptor_.
|
inline |
Sets socket option.
socket_option | Reference to the object encapsulating an option to be set for the socket. |
SettableSocketOption | Type of the object encapsulating socket option being set. |
Definition at line 82 of file io_acceptor.h.
References 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().
|
protected |
The IO service used to handle events.
Definition at line 123 of file io_acceptor.h.
Referenced by IOAcceptor().