#include <acceptor.hpp>
Inherits matador::handler, and handler_creator.
Public Types | |
typedef std::function< std::shared_ptr< handler >(tcp::socket sock, tcp::peer endpoint, acceptor *accptr)> | t_accept_handler |
Public Member Functions | |
acceptor () | |
acceptor (tcp::peer endpoint) | |
acceptor (tcp::peer endpoint, t_accept_handler on_new_connection) | |
~acceptor () override | |
void | accecpt (t_accept_handler on_new_connection) |
void | accecpt (const tcp::peer &endpoint, t_accept_handler on_new_connection) |
void | open () override |
socket_type | handle () const override |
void | on_input () override |
void | on_output () override |
void | on_except () override |
void | on_timeout () override |
void | on_close () override |
void | close () override |
bool | is_ready_write () const override |
bool | is_ready_read () const override |
void | notify_close (handler *hndlr) override |
std::string | name () const override |
const tcp::peer & | endpoint () const |
Public Member Functions inherited from matador::handler | |
virtual | ~handler ()=default |
time_t | next_timeout () const |
time_t | interval () const |
Additional Inherited Members | |
Protected Member Functions inherited from matador::handler | |
reactor * | get_reactor () const |
The acceptor class is used to accept new connection within the reactor dispatcher.
Once a new connection was accepted by the acceptor a new handler is created and registered within the reactor to handle the established connection
typedef std::function<std::shared_ptr<handler>(tcp::socket sock, tcp::peer endpoint, acceptor *accptr)> matador::acceptor::t_accept_handler |
Shortcut to a function creating a handler on successfully accepted a new connection
matador::acceptor::acceptor | ( | ) |
Default constructor
|
explicit |
Creates an acceptor with the given endpoint. The endpoint represents the address on which the acceptor listens for new connections
endpoint | Endpoint to listen for new connections |
matador::acceptor::acceptor | ( | tcp::peer | endpoint, |
t_accept_handler | on_new_connection | ||
) |
Creates an acceptor with the given endpoint. The endpoint represents the address on which the acceptor listens for new connections. The given function is called when a new connection was accepted and returns a new handler for the new connection.
endpoint | Endpoint to listen for new connections |
on_new_connection | Function creating a new handler for each accepted new connection |
|
override |
Destructor
void matador::acceptor::accecpt | ( | const tcp::peer & | endpoint, |
t_accept_handler | on_new_connection | ||
) |
Accepts new connection at the given endpoint. When a new connection is accepted the given function is called to create a new handler for the connection.
endpoint | Endpoint to listen for new connections |
on_new_connection | Function creating a new handler for the new connection |
void matador::acceptor::accecpt | ( | t_accept_handler | on_new_connection | ) |
When a new connection is accepted the given function is called to create a new handler for the connection
on_new_connection | Function creating a new handler for the new connection |
|
overridevirtual |
Closes the listen fd of the acceptor
Implements matador::handler.
const tcp::peer & matador::acceptor::endpoint | ( | ) | const |
Returns the current endpoint accepting new connection.
|
overridevirtual |
|
overridevirtual |
Returns true if the acceptor was opened and a listen fd was created.
Implements matador::handler.
|
overridevirtual |
Returns always false because new connections are indicated as read events.
Implements matador::handler.
|
overridevirtual |
Get the name of the handler. The name don't need to be unique. It has only an informational purpose.
Implements matador::handler.
|
override |
Notifies the acceptor that this handler was closed.
hndlr | Closed handler. |
|
inlineoverridevirtual |
Does actually nothing
Implements matador::handler.
|
inlineoverridevirtual |
Does actually nothing
Implements matador::handler.
|
overridevirtual |
Is called when a new connection wants to execute to the endpoint. Once the connection was accepted a new connection handler is created and the socket is passed to the handler. The handler is then registered to the reactor to disptach its read and write events.
Implements matador::handler.
|
inlineoverridevirtual |
Does actually nothing
Implements matador::handler.
|
inlineoverridevirtual |
Does actually nothing
Implements matador::handler.
|
overridevirtual |
Opens the acceptor means the socket address of the endpoint is bound to the created listing socket Then the socket is used for listening for new connections.
Implements matador::handler.