#include <stream_handler.hpp>
Inherits matador::handler, and matador::io_stream.
The stream_handler class implements the handler and io_stream interface and is used with the io_service to handle socket connections more easily in comparison with the plain reactor boilerplate.
Instances of the class are used internally within the io_service hiding the read and write wiring. The user just use the interface provided by the io_service to setup a server.
◆ t_init_handler
Shortcut to the initialize function
◆ stream_handler()
Creates a new stream_handler for the given socket. The acceptor is the link to the creation source where the given init function is called when the handler is initialized
- Parameters
-
sock | Socket to read and write on |
endpoint | Endpoint of the connection |
creator | Pointer to the creating handler class |
init_handler | Initialize function |
◆ close()
void matador::stream_handler::close |
( |
| ) |
|
|
overridevirtual |
Interface implementation should close the handle gracefully
Implements matador::handler.
◆ close_stream()
void matador::stream_handler::close_stream |
( |
| ) |
|
|
overridevirtual |
◆ handle()
socket_type matador::stream_handler::handle |
( |
| ) |
const |
|
overridevirtual |
Interface to returns the socket handle of the concrete handler implementation.
- Returns
- The socket fd
Implements matador::handler.
◆ is_ready_read()
bool matador::stream_handler::is_ready_read |
( |
| ) |
const |
|
overridevirtual |
Interface should return true if there is incoming data
- Returns
- True if there is incoming data
Implements matador::handler.
◆ is_ready_write()
bool matador::stream_handler::is_ready_write |
( |
| ) |
const |
|
overridevirtual |
Interface should return true if there is outgoing data
- Returns
- True if there is outgoing data
Implements matador::handler.
◆ name()
std::string matador::stream_handler::name |
( |
| ) |
const |
|
overridevirtual |
Get the name of the handler. The name don't need to be unique. It has only an informational purpose.
- Returns
- The name of the handler
Implements matador::handler.
◆ on_close()
void matador::stream_handler::on_close |
( |
| ) |
|
|
overridevirtual |
◆ on_except()
void matador::stream_handler::on_except |
( |
| ) |
|
|
inlineoverridevirtual |
◆ on_input()
void matador::stream_handler::on_input |
( |
| ) |
|
|
overridevirtual |
◆ on_output()
void matador::stream_handler::on_output |
( |
| ) |
|
|
overridevirtual |
◆ on_timeout()
void matador::stream_handler::on_timeout |
( |
| ) |
|
|
inlineoverridevirtual |
◆ open()
void matador::stream_handler::open |
( |
| ) |
|
|
overridevirtual |
Interface to open a handler. This is called when a handler is registered within the reactor
Implements matador::handler.
◆ read()
This interface is called when data should be read from a socket. Once the date was read the given read handler is called.
- Parameters
-
buf | Buffer to read the data in |
read_handler | Handler to be called when data was read |
Implements matador::io_stream.
◆ stream()
◆ write()
This interface is called when data should be written to a socket. Once the data was written the given write handler is called.
- Parameters
-
buffers | List of buffers containing the data to write |
write_handler | Handler to be called when the data was written |
Implements matador::io_stream.
The documentation for this class was generated from the following file:
- matador/net/stream_handler.hpp