Packet¶
Functions
- 
sfPacket *sfPacket_copy(const sfPacket *packet)¶
 Create a new packet by copying an existing one.
- Parameters:
 packet – Packet to copy
- Returns:
 A new sfPacket object which is a copy of packet
- 
void sfPacket_destroy(const sfPacket *packet)¶
 Destroy a packet.
- Parameters:
 packet – Packet to destroy
- 
void sfPacket_append(sfPacket *packet, const void *data, size_t sizeInBytes)¶
 Append data to the end of a packet.
- Parameters:
 packet – Packet object
data – Pointer to the sequence of bytes to append
sizeInBytes – Number of bytes to append
- 
size_t sfPacket_getReadPosition(const sfPacket *packet)¶
 Get the current reading position in the packet.
The next read operation will read data from this position
See also
append
- Parameters:
 packet – Packet object
- Returns:
 The byte offset of the current read position
- 
void sfPacket_clear(sfPacket *packet)¶
 Clear a packet.
After calling Clear, the packet is empty.
- Parameters:
 packet – Packet object
- 
const void *sfPacket_getData(const sfPacket *packet)¶
 Get a pointer to the data contained in a packet.
Warning: the returned pointer may become invalid after you append data to the packet, therefore it should never be stored. The return pointer is NULL if the packet is empty.
- Parameters:
 packet – Packet object
- Returns:
 Pointer to the data
- 
size_t sfPacket_getDataSize(const sfPacket *packet)¶
 Get the size of the data contained in a packet.
This function returns the number of bytes pointed to by what sfPacket_getData returns.
- Parameters:
 packet – Packet object
- Returns:
 Data size, in bytes
- 
bool sfPacket_endOfPacket(const sfPacket *packet)¶
 Tell if the reading position has reached the end of a packet.
This function is useful to know if there is some data left to be read, without actually reading it.
- Parameters:
 packet – Packet object
- Returns:
 true if all data was read, false otherwise
- 
bool sfPacket_canRead(const sfPacket *packet)¶
 Test the validity of a packet, for reading.
This function allows for testing the packet, to check if a reading operation was successful.
A packet will be in an invalid state if it has no more data to read.
- Parameters:
 packet – Packet object
- Returns:
 true if last data extraction from packet was successful
- 
bool sfPacket_readBool(sfPacket *packet)¶
 Functions to extract data from a packet.
- Parameters:
 packet – Packet object