IAtari
Genetic algorithm generating AI capable to play Atari2600 games.
connection Class Reference

Handle networking. More...

#include <connection.hpp>

Public Member Functions

 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...
 

Private Member Functions

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...
 

Private Attributes

boost::asio::ip::tcp::socket socket
 

Static Private Attributes

static constexpr int HEADER_LENGTH = 8
 

Detailed Description

Handle networking.

Constructor & Destructor Documentation

◆ connection()

connection::connection ( boost::asio::ip::tcp::socket  socket)
inline

Standard constructor. Initialize the connection by moving a socket.

Parameters
socketThe associated socket

◆ ~connection()

connection::~connection ( )
inline

Standard destructor. Close the associated socket.

Member Function Documentation

◆ 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]tValue to be read
yieldContext 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]tValue to be writen
yieldContext object, represents the currently executing coroutine.

◆ close()

connection::close ( )
inline

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
headerInt 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.

Member Data Documentation

◆ 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: