118 [[nodiscard]]
size_t size() const noexcept {
return buffer.size(); }
DatagramPacket(const char *data, const size_t len, std::string addr, const Port prt)
Construct a DatagramPacket from a raw pointer/size and destination info.
Definition DatagramPacket.hpp:97
void resize(const size_t newSize)
Resize the packet's internal buffer.
Definition DatagramPacket.hpp:112
size_t size() const noexcept
Get the current size of the buffer (valid bytes for receive/send).
Definition DatagramPacket.hpp:118
DatagramPacket(std::string_view data, std::string addr, const Port prt)
Construct a DatagramPacket from a string_view and destination info.
Definition DatagramPacket.hpp:84
std::vector< char > buffer
Data buffer for the packet payload.
Definition DatagramPacket.hpp:56
DatagramPacket(DatagramPacket &&) noexcept=default
Port port
Remote UDP port for the destination/source.
Definition DatagramPacket.hpp:70
void clear()
Reset the packet (clears buffer, address, and port).
Definition DatagramPacket.hpp:123
DatagramPacket(const size_t size=0)
Construct an empty DatagramPacket with a specified buffer size.
Definition DatagramPacket.hpp:76
std::string address
Remote address (IPv4/IPv6) for the destination/source.
Definition DatagramPacket.hpp:63
DatagramPacket(const DatagramPacket &)=default
Common platform and utility includes for jsocketpp.
std::uint16_t Port
Type alias representing a TCP or UDP port number (1–65535).
Definition common.hpp:315
A C++ socket library providing Java-style networking interfaces.
Definition BufferView.hpp:13