#include <icy/net/socket.h>Inherits:
RawPacket
Default packet type emitted by sockets.
SocketPacket carries the remote peer address plus a borrowed view of the received byte buffer for zero-copy processing inside the receive callback.
The referenced packet buffer lifetime is only guaranteed for the duration of the receiver callback.
| Return | Name | Description |
|---|---|---|
SocketPacket inline | Constructs a SocketPacket wrapping the received buffer. | |
SocketPacket inline | Copy constructor; shares the underlying buffer reference. | |
PacketInfo * | packetInfo const inline | Returns the PacketInfo for this socket packet. |
void | print virtual const inline | Prints a one-line description of the packet to os. |
std::unique_ptr< IPacket > | clone virtual const inline | Returns a heap-allocated copy of this SocketPacket. |
ssize_t | read virtual inline | Not supported; always throws std::logic_error. |
void | write virtual const inline | Appends the packet payload to buf. |
const char * | className virtual const inline | #### Returns |
inline
inline SocketPacket(const Socket::Ptr & socket, const MutableBuffer & buffer, const Address & peerAddress)Constructs a SocketPacket wrapping the received buffer.
The buffer data pointer remains valid only for the duration of the enclosing receive callback; do not retain references beyond that scope.
socket Shared pointer to the receiving socket.
buffer View of the raw received bytes.
peerAddress Address of the remote sender.
inline
inline SocketPacket(const SocketPacket & that)Copy constructor; shares the underlying buffer reference.
that Source SocketPacket to copy.const inline
inline PacketInfo * packetInfo() constReturns the PacketInfo for this socket packet.
Pointer to the associated PacketInfo (never null for a valid packet).
virtual const inline
virtual inline void print(std::ostream & os) constPrints a one-line description of the packet to os.
os Output stream to write to.virtual const inline
virtual inline std::unique_ptr< IPacket > clone() constReturns a heap-allocated copy of this SocketPacket.
virtual inline
virtual inline ssize_t read(const ConstBuffer &)Not supported; always throws std::logic_error.
virtual const inline
virtual inline void write(Buffer & buf) constAppends the packet payload to buf.
buf Destination buffer to append raw bytes to.virtual const inline
virtual inline const char * className() constThe string "SocketPacket".