39 TCP(asio::io_context &io_context,
const std::string &ip,
int port,
bool is_sender);
50 void sendTo(
const std::string &message);
84 asio::io_context &_io_context;
85 asio::ip::tcp::socket _socket;
86 asio::ip::tcp::acceptor _acceptor;
88 std::queue<std::string> _received_packets;
89 std::shared_ptr<std::thread> _server_thread;
Aggregates logging-related headers.
A class for handling TCP network communication.
~TCP()
Destroy the TCP object.
TCP(asio::io_context &io_context, const std::string &ip, int port, bool is_sender)
Construct a new TCP object.
std::string fetchPacket()
Fetch a packet from the received packets queue.
bool isConnectionAlive()
Check if the connection is alive.
void sendTo(const std::string &message)
Send a message to the connected peer.
std::string receive()
Receive a message from the connected peer.