A class for handling UDP network communication.
More...
#include <UDP.hpp>
|
| | 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.
|
| |
| void | sendRaw (const char *data, std::size_t size, const std::string &address, int port) |
| | Send raw data to a specified address and port.
|
| |
| std::string | receiveFrom (std::string &address, int &port) |
| | Receive a message from a specified address and port.
|
| |
| bool | isConnectionAlive () |
| | Check if the connection is alive.
|
| |
| std::string | fetchPacket () |
| | Fetch a packet from the received packets queue.
|
| |
A class for handling UDP network communication.
Definition at line 27 of file UDP.hpp.
◆ UDP()
| Network::UDP::UDP |
( |
asio::io_context & | io_context, |
|
|
const std::string & | ip, |
|
|
int | port, |
|
|
bool | is_sender ) |
Construct a new UDP object.
Constructs a new UDP 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 UDP object is for sending, false if for receiving. |
Definition at line 26 of file UDP.cpp.
◆ ~UDP()
Destroy the UDP object.
Destroys the UDP object.
Definition at line 42 of file UDP.cpp.
◆ fetchPacket()
| std::string Network::UDP::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 122 of file UDP.cpp.
◆ isConnectionAlive()
| bool Network::UDP::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 112 of file UDP.cpp.
◆ receiveFrom()
| std::string Network::UDP::receiveFrom |
( |
std::string & | address, |
|
|
int & | port ) |
Receive a message from a specified address and port.
Receives a message from a remote endpoint.
- Parameters
-
| address | The source IP address. |
| port | The source port number. |
- Returns
- The received message.
Definition at line 81 of file UDP.cpp.
◆ sendRaw()
| void Network::UDP::sendRaw |
( |
const char * | data, |
|
|
std::size_t | size, |
|
|
const std::string & | address, |
|
|
int | port ) |
Send raw data to a specified address and port.
Sends raw data to the specified address and port.
- Parameters
-
| data | The raw data to send. |
| size | The size of the data. |
| address | The destination IP address. |
| port | The destination port number. |
Definition at line 68 of file UDP.cpp.
◆ sendTo()
| void Network::UDP::sendTo |
( |
const std::string & | message, |
|
|
const std::string & | address, |
|
|
int | port ) |
Send a message to a specified address and port.
Sends a message to the specified address and port.
- Parameters
-
| message | The message to send. |
| address | The destination IP address. |
| port | The destination port number. |
Definition at line 54 of file UDP.cpp.
The documentation for this class was generated from the following files: