Babel  1
The voip software that only works on your local network
Loading...
Searching...
No Matches
Network::TCP Class Reference

A class for handling TCP network communication. More...

#include <TCP.hpp>

Collaboration diagram for Network::TCP:
Collaboration graph

Public Member Functions

 TCP (asio::io_context &io_context, const std::string &ip, int port, bool is_sender)
 Construct a new TCP object.
 
 ~TCP ()
 Destroy the TCP object.
 
void sendTo (const std::string &message)
 Send a message to the connected peer.
 
std::string receive ()
 Receive a message from the connected peer.
 
bool isConnectionAlive ()
 Check if the connection is alive.
 
std::string fetchPacket ()
 Fetch a packet from the received packets queue.
 

Detailed Description

A class for handling TCP network communication.

Definition at line 29 of file TCP.hpp.

Constructor & Destructor Documentation

◆ TCP()

Network::TCP::TCP ( asio::io_context & io_context,
const std::string & ip,
int port,
bool is_sender )

Construct a new TCP object.

Constructs a new TCP object.

Parameters
io_contextThe ASIO I/O context.
ipThe IP address to bind or connect to.
portThe port number to bind or connect to.
is_senderIndicates whether the instance is for sending or receiving.
io_contextThe ASIO I/O context.
ipThe IP address to bind or connect to.
portThe port number to bind or connect to.
is_senderTrue if the TCP object is for sending, false if for receiving.

Definition at line 19 of file TCP.cpp.

◆ ~TCP()

Network::TCP::~TCP ( )

Destroy the TCP object.

Destroys the TCP object.

Definition at line 43 of file TCP.cpp.

Member Function Documentation

◆ fetchPacket()

std::string Network::TCP::fetchPacket ( )

Fetch a packet from the received packets queue.

Fetches a received packet from the queue.

Returns
The fetched packet.
The received packet.

Definition at line 127 of file TCP.cpp.

◆ isConnectionAlive()

bool Network::TCP::isConnectionAlive ( )

Check if the connection is alive.

Checks if the connection is alive.

Returns
true if the connection is alive; false otherwise.
True if the connection is alive, otherwise false.

Definition at line 117 of file TCP.cpp.

◆ receive()

std::string Network::TCP::receive ( )

Receive a message from the connected peer.

Receives a message from the connected endpoint.

Returns
The received message.

Definition at line 102 of file TCP.cpp.

◆ sendTo()

void Network::TCP::sendTo ( const std::string & message)

Send a message to the connected peer.

Sends a message to the connected endpoint.

Parameters
messageThe message to send.

Definition at line 57 of file TCP.cpp.


The documentation for this class was generated from the following files: