SocketPacket
SocketPacket
#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.
Public Methods
| 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 |
SocketPacket
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.
Parameters
socketShared pointer to the receiving socket.bufferView of the raw received bytes.peerAddressAddress of the remote sender.
SocketPacket
inline
inline SocketPacket(const SocketPacket & that)Copy constructor; shares the underlying buffer reference.
Parameters
thatSource SocketPacket to copy.
packetInfo
const inline
inline PacketInfo * packetInfo() constReturns the PacketInfo for this socket packet.
Returns
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.
Parameters
osOutput stream to write to.
clone
virtual const inline
virtual inline std::unique_ptr< IPacket > clone() constReturns a heap-allocated copy of this SocketPacket.
read
virtual inline
virtual inline ssize_t read(const ConstBuffer &)Not supported; always throws std::logic_error.
write
virtual const inline
virtual inline void write(Buffer & buf) constAppends the packet payload to buf.
Parameters
bufDestination buffer to append raw bytes to.
className
virtual const inline
virtual inline const char * className() constReturns
The string "SocketPacket".
