A class for handling TCP network communication.
More...
#include <TCP.hpp>
|
| | 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.
|
| |
A class for handling TCP network communication.
Definition at line 29 of file TCP.hpp.
◆ 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_context | The ASIO I/O context. |
| ip | The IP address to bind or connect to. |
| port | The port number to bind or connect to. |
| is_sender | Indicates whether the instance is for sending or receiving. |
| io_context | The ASIO I/O context. |
| ip | The IP address to bind or connect to. |
| port | The port number to bind or connect to. |
| is_sender | True if the TCP object is for sending, false if for receiving. |
Definition at line 19 of file TCP.cpp.
◆ ~TCP()
Destroy the TCP object.
Destroys the TCP object.
Definition at line 43 of file TCP.cpp.
◆ 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
-
| message | The message to send. |
Definition at line 57 of file TCP.cpp.
The documentation for this class was generated from the following files: