Handle networking.
More...
#include <connection.hpp>
|
| connection (boost::asio::ip::tcp::socket socket) |
| Standard constructor. Initialize the connection by moving a socket. More...
|
|
| ~connection () |
| Standard destructor. Close the associated socket. More...
|
|
void | close () |
| Disable then close the socket. May return an error if it fails to disable the socket. More...
|
|
boost::asio::ip::tcp::socket & | get_socket () |
| Return the associated socket. More...
|
|
void | async_write (const T &t, boost::asio::yield_context yield) |
| Write a value through the associated socket. More...
|
|
void | async_read (T &t, boost::asio::yield_context yield) |
| Read a value through the associated socket. May return an error if the inner inputStream can't be read. More...
|
|
|
std::string | create_outbound_header (int header) |
| Transform an int into his hexadecimal value. May return an error if the inner outputStream is not properly initialized. More...
|
|
|
boost::asio::ip::tcp::socket | socket |
|
◆ connection()
connection::connection |
( |
boost::asio::ip::tcp::socket |
socket | ) |
|
|
inline |
Standard constructor. Initialize the connection by moving a socket.
- Parameters
-
socket | The associated socket |
◆ ~connection()
connection::~connection |
( |
| ) |
|
|
inline |
Standard destructor. Close the associated socket.
◆ async_read()
connection::async_read |
( |
T & |
t, |
|
|
boost::asio::yield_context |
yield |
|
) |
| |
|
inline |
Read a value through the associated socket. May return an error if the inner inputStream can't be read.
- Parameters
-
[out] | t | Value to be read |
| yield | Context object, represents the currently executing coroutine. |
◆ async_write()
connection::async_write |
( |
const T & |
t, |
|
|
boost::asio::yield_context |
yield |
|
) |
| |
|
inline |
Write a value through the associated socket.
- Parameters
-
[in] | t | Value to be writen |
| yield | Context object, represents the currently executing coroutine. |
◆ close()
Disable then close the socket. May return an error if it fails to disable the socket.
◆ create_outbound_header()
connection::create_outbound_header |
( |
int |
header | ) |
|
|
inlineprivate |
Transform an int into his hexadecimal value. May return an error if the inner outputStream is not properly initialized.
- Parameters
-
header | Int value to be transformed |
- Returns
- The hexadecimal value as a string
◆ get_socket()
connection::get_socket |
( |
| ) |
|
|
inline |
Return the associated socket.
- Returns
- The associated socket.
◆ HEADER_LENGTH
constexpr int connection::HEADER_LENGTH = 8 |
|
staticprivate |
Length of the outputStream's header
◆ socket
boost::asio::ip::tcp::socket connection::socket |
|
private |
The socket used to transfer informations
The documentation for this class was generated from the following file: