37 UDP(asio::io_context &io_context,
const std::string &ip,
int port,
bool is_sender);
50 void sendTo(
const std::string &message,
const std::string &address,
int port);
60 void sendRaw(
const char *data, std::size_t size,
const std::string &address,
int port);
69 std::string
receiveFrom(std::string &address,
int &port);
87 asio::ip::udp::socket _socket;
88 std::queue<std::string> _received_packets;
Aggregates logging-related headers.
A class for handling UDP network communication.
std::string fetchPacket()
Fetch a packet from the received packets queue.
void sendRaw(const char *data, std::size_t size, const std::string &address, int port)
Send raw data to a specified address and port.
UDP(asio::io_context &io_context, const std::string &ip, int port, bool is_sender)
Construct a new UDP object.
~UDP()
Destroy the UDP object.
void sendTo(const std::string &message, const std::string &address, int port)
Send a message to a specified address and port.
bool isConnectionAlive()
Check if the connection is alive.
std::string receiveFrom(std::string &address, int &port)
Receive a message from a specified address and port.