A UDP Packet.
More...
#include <udp.h>
|
| packet (const connection &dst, const std::string &data) |
| Create a packet from a string.
|
|
| packet (const std::string &in) |
| Construct a packet from a string buffer.
|
|
template<typename T > |
| packet (const connection &dst, const T &data, const size_t &size) |
| Construct a packet from any variable data, and its size.
|
|
std::string | str () const |
| Print the packet.
|
|
template<typename T > |
const T | cast () const |
| Cast the content of the packet as a type.
|
|
std::string | data () const |
| Return the data.
|
|
std::string | buffer () const |
| Create a buffer of the packet that can be sent across the network.
|
|
connection | destination () const |
| Get the address and port of the destination.
|
|
connection | source () const |
| Get the address and port of the source.
|
|
◆ packet() [1/3]
udp::packet::packet |
( |
const connection & | dst, |
|
|
const std::string & | data ) |
|
inline |
Create a packet from a string.
- Parameters
-
dst | The connection receiving the packet. |
data | The data string to send. |
- Warning
- This function will only take UINT16_MAX bytes from the data string.
◆ packet() [2/3]
udp::packet::packet |
( |
const std::string & | in | ) |
|
|
inline |
Construct a packet from a string buffer.
- Parameters
-
◆ packet() [3/3]
template<typename T >
udp::packet::packet |
( |
const connection & | dst, |
|
|
const T & | data, |
|
|
const size_t & | size ) |
|
inline |
Construct a packet from any variable data, and its size.
- Parameters
-
dst | The destination. |
data | The data to store. |
size | The size of that data. |
◆ buffer()
std::string udp::packet::buffer |
( |
| ) |
const |
|
inline |
Create a buffer of the packet that can be sent across the network.
- Returns
- The buffer.
◆ cast()
template<typename T >
const T udp::packet::cast |
( |
| ) |
const |
|
inline |
Cast the content of the packet as a type.
- Template Parameters
-
- Returns
- The casted value.
◆ data()
std::string udp::packet::data |
( |
| ) |
const |
|
inline |
Return the data.
- Returns
- The data.
◆ destination()
Get the address and port of the destination.
- Returns
- The connection.
◆ empty()
An empty packet.
- Parameters
-
- Returns
- The empty packet.
◆ source()
Get the address and port of the source.
- Returns
- The connection.
◆ str()
std::string udp::packet::str |
( |
| ) |
const |
|
inline |
Print the packet.
- Returns
- The string.
The documentation for this class was generated from the following file: