SocketPacket
SocketPacket
#include <icy/net/socket.h>class SocketPacketDefined in src/net/include/icy/net/socket.h:200
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.
List of all members
| Name | Kind | Owner |
|---|---|---|
SocketPacket | function | Declared here |
SocketPacket | function | Declared here |
packetInfo | function | Declared here |
~SocketPacket | function | Declared here |
print | function | Declared here |
clone | function | Declared here |
read | function | Declared here |
write | function | Declared here |
className | function | Declared here |
RawPacket | function | Inherited from RawPacket |
RawPacket | function | Inherited from RawPacket |
RawPacket | function | Inherited from RawPacket |
~RawPacket | function | Inherited from RawPacket |
clone | function | Inherited from RawPacket |
copyData | function | Inherited from RawPacket |
read | function | Inherited from RawPacket |
write | function | Inherited from RawPacket |
data | function | Inherited from RawPacket |
size | function | Inherited from RawPacket |
className | function | Inherited from RawPacket |
ownsBuffer | function | Inherited from RawPacket |
_data | variable | Inherited from RawPacket |
_size | variable | Inherited from RawPacket |
_owned | variable | Inherited from RawPacket |
operator<< | friend | Inherited from IPacket |
opaque | variable | Inherited from IPacket |
info | variable | Inherited from IPacket |
flags | variable | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
IPacket | function | Inherited from IPacket |
operator= | function | Inherited from IPacket |
clone | function | Inherited from IPacket |
~IPacket | function | Inherited from IPacket |
read | function | Inherited from IPacket |
write | function | Inherited from IPacket |
size | function | Inherited from IPacket |
hasData | function | Inherited from IPacket |
data | function | Inherited from IPacket |
constData | function | Inherited from IPacket |
className | function | Inherited from IPacket |
print | function | Inherited from IPacket |
Inherited from RawPacket
| Kind | Name | Description |
|---|---|---|
function | RawPacket inline | Construct with borrowed (non-owning) buffer. |
function | RawPacket inline | Construct with const data (copied, owning). |
function | RawPacket inline | Copy constructor (always copies data). |
function | ~RawPacket virtual | Defaulted destructor. |
function | clone virtual const inline override | |
function | copyData virtual inline | Copies data into an internally owned buffer, replacing any prior content. |
function | read virtual inline override | Reads from the buffer by copying its contents into an owned buffer. |
function | write virtual const inline override | Appends the packet data to the given output buffer. |
function | data virtual const inline override | |
function | size virtual const inline override | |
function | className virtual const inline override | Returns the class name of this packet type for logging and diagnostics. |
function | ownsBuffer const inline | |
variable | _data | |
variable | _size | |
variable | _owned |
Inherited from IPacket
| Kind | Name | Description |
|---|---|---|
friend | operator<< inline | Stream insertion operator; delegates to print(). |
variable | opaque | Optional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime. |
variable | info | Optional extra information about the packet. |
variable | flags | Provides basic information about the packet. |
function | IPacket inline | |
function | IPacket inline | Copy constructor; clones the info object if present. |
function | operator= inline | Copy assignment; clones the info object if present. |
function | clone virtual const | Returns a heap-allocated deep copy of this packet. |
function | ~IPacket virtual | Defaulted destructor. |
function | read virtual | Read/parse to the packet from the given input buffer. The number of bytes read is returned. |
function | write virtual const | Copy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer. |
function | size virtual const inline | The size of the packet in bytes. |
function | hasData virtual const inline | Returns true if the packet has a non-null data pointer. |
function | data virtual const inline | The packet data pointer for buffered packets. |
function | constData virtual const inline | The const packet data pointer for buffered packets. |
function | className virtual const | Returns the class name of this packet type for logging and diagnostics. |
function | print virtual const inline | Prints a human-readable representation to the given stream. |
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 |
SocketPacket
inline
inline SocketPacket(const Socket::Ptr & socket, const MutableBuffer & buffer, const Address & peerAddress)Defined in src/net/include/icy/net/socket.h:210
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)Defined in src/net/include/icy/net/socket.h:218
Copy constructor; shares the underlying buffer reference.
Parameters
thatSource SocketPacket to copy.
packetInfo
const inline
inline PacketInfo * packetInfo() constDefined in src/net/include/icy/net/socket.h:225
Returns 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) constDefined in src/net/include/icy/net/socket.h:234
Prints a one-line description of the packet to os.
Parameters
osOutput stream to write to.
Reimplements
clone
virtual const inline
virtual inline std::unique_ptr< IPacket > clone() constDefined in src/net/include/icy/net/socket.h:240
Returns a heap-allocated copy of this SocketPacket.
Reimplements
read
virtual inline
virtual inline ssize_t read(const ConstBuffer &)Defined in src/net/include/icy/net/socket.h:243
Not supported; always throws std::logic_error.
Reimplements
write
virtual const inline
virtual inline void write(Buffer & buf) constDefined in src/net/include/icy/net/socket.h:251
Appends the packet payload to buf.
Parameters
bufDestination buffer to append raw bytes to.
Reimplements
className
virtual const inline
virtual inline const char * className() constDefined in src/net/include/icy/net/socket.h:258
Returns
The string "SocketPacket".
