Packet
in package
Represents a raw network data packet
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Constructor
- getBytesRemaining() : int
- Get the number of remaining bytes from the pointer position
- getLength() : int
- Get the data length
- getPointer() : int
- Get the pointer index
- read() : string
- Read bytes from the packet data
- reset() : mixed
- Reset the read pointer
- write() : int
- Append data to the packet
Properties
$data
private
string
$data
$length
private
int
$length
Data length
$pointer
private
int
$pointer
= 0
Read pointer
Methods
__construct()
Constructor
public
__construct([string $data = '' ]) : mixed
Parameters
- $data : string = ''
-
The initial packet raw data
getBytesRemaining()
Get the number of remaining bytes from the pointer position
public
getBytesRemaining() : int
Return values
intgetLength()
Get the data length
public
getLength() : int
Return values
intgetPointer()
Get the pointer index
public
getPointer() : int
Return values
intread()
Read bytes from the packet data
public
read([int $length = null ]) : string
Parameters
- $length : int = null
-
The number of bytes to read
Tags
Return values
stringreset()
Reset the read pointer
public
reset() : mixed
write()
Append data to the packet
public
write(string $data) : int
Parameters
- $data : string
-
The data to append
Return values
int —The number of bytes written