Home
Net module

SocketPacket

Default packet type emitted by sockets.

SocketPacket

#include <icy/net/socket.h>
class SocketPacket

Defined 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

NameKindOwner
SocketPacketfunctionDeclared here
SocketPacketfunctionDeclared here
packetInfofunctionDeclared here
~SocketPacketfunctionDeclared here
printfunctionDeclared here
clonefunctionDeclared here
readfunctionDeclared here
writefunctionDeclared here
classNamefunctionDeclared here
RawPacketfunctionInherited from RawPacket
RawPacketfunctionInherited from RawPacket
RawPacketfunctionInherited from RawPacket
~RawPacketfunctionInherited from RawPacket
clonefunctionInherited from RawPacket
copyDatafunctionInherited from RawPacket
readfunctionInherited from RawPacket
writefunctionInherited from RawPacket
datafunctionInherited from RawPacket
sizefunctionInherited from RawPacket
classNamefunctionInherited from RawPacket
ownsBufferfunctionInherited from RawPacket
_datavariableInherited from RawPacket
_sizevariableInherited from RawPacket
_ownedvariableInherited from RawPacket
operator<<friendInherited from IPacket
opaquevariableInherited from IPacket
infovariableInherited from IPacket
flagsvariableInherited from IPacket
IPacketfunctionInherited from IPacket
IPacketfunctionInherited from IPacket
operator=functionInherited from IPacket
clonefunctionInherited from IPacket
~IPacketfunctionInherited from IPacket
readfunctionInherited from IPacket
writefunctionInherited from IPacket
sizefunctionInherited from IPacket
hasDatafunctionInherited from IPacket
datafunctionInherited from IPacket
constDatafunctionInherited from IPacket
classNamefunctionInherited from IPacket
printfunctionInherited from IPacket

Inherited from RawPacket

KindNameDescription
functionRawPacket inlineConstruct with borrowed (non-owning) buffer.
functionRawPacket inlineConstruct with const data (copied, owning).
functionRawPacket inlineCopy constructor (always copies data).
function~RawPacket virtualDefaulted destructor.
functionclone virtual const inline override
functioncopyData virtual inlineCopies data into an internally owned buffer, replacing any prior content.
functionread virtual inline overrideReads from the buffer by copying its contents into an owned buffer.
functionwrite virtual const inline overrideAppends the packet data to the given output buffer.
functiondata virtual const inline override
functionsize virtual const inline override
functionclassName virtual const inline overrideReturns the class name of this packet type for logging and diagnostics.
functionownsBuffer const inline
variable_data
variable_size
variable_owned

Inherited from IPacket

KindNameDescription
friendoperator<< inlineStream insertion operator; delegates to print().
variableopaqueOptional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime.
variableinfoOptional extra information about the packet.
variableflagsProvides basic information about the packet.
functionIPacket inline
functionIPacket inlineCopy constructor; clones the info object if present.
functionoperator= inlineCopy assignment; clones the info object if present.
functionclone virtual constReturns a heap-allocated deep copy of this packet.
function~IPacket virtualDefaulted destructor.
functionread virtualRead/parse to the packet from the given input buffer. The number of bytes read is returned.
functionwrite virtual constCopy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer.
functionsize virtual const inlineThe size of the packet in bytes.
functionhasData virtual const inlineReturns true if the packet has a non-null data pointer.
functiondata virtual const inlineThe packet data pointer for buffered packets.
functionconstData virtual const inlineThe const packet data pointer for buffered packets.
functionclassName virtual constReturns the class name of this packet type for logging and diagnostics.
functionprint virtual const inlinePrints a human-readable representation to the given stream.

Public Methods

ReturnNameDescription
SocketPacket inlineConstructs a SocketPacket wrapping the received buffer.
SocketPacket inlineCopy constructor; shares the underlying buffer reference.
PacketInfo *packetInfo const inlineReturns the PacketInfo for this socket packet.
voidprint virtual const inlinePrints a one-line description of the packet to os.
std::unique_ptr< IPacket >clone virtual const inlineReturns a heap-allocated copy of this SocketPacket.
ssize_tread virtual inlineNot supported; always throws std::logic_error.
voidwrite virtual const inlineAppends 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

  • socket Shared pointer to the receiving socket.

  • buffer View of the raw received bytes.

  • peerAddress Address 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


packetInfo

const inline

inline PacketInfo * packetInfo() const

Defined 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).


print

virtual const inline

virtual inline void print(std::ostream & os) const

Defined in src/net/include/icy/net/socket.h:234

Prints a one-line description of the packet to os.

Parameters

  • os Output stream to write to.
Reimplements

clone

virtual const inline

virtual inline std::unique_ptr< IPacket > clone() const

Defined 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) const

Defined in src/net/include/icy/net/socket.h:251

Appends the packet payload to buf.

Parameters

  • buf Destination buffer to append raw bytes to.
Reimplements

className

virtual const inline

virtual inline const char * className() const

Defined in src/net/include/icy/net/socket.h:258

Returns

The string "SocketPacket".

Reimplements