Documentation

Packet
in package

Represents a raw network data packet

Tags
category

LibDNS

author

Chris Wright https://github.com/DaveRandom

Table of Contents

Properties

$data  : string
$length  : int
$pointer  : int

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

$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
int

getLength()

Get the data length

public getLength() : int
Return values
int

getPointer()

Get the pointer index

public getPointer() : int
Return values
int

read()

Read bytes from the packet data

public read([int $length = null ]) : string
Parameters
$length : int = null

The number of bytes to read

Tags
throws
OutOfBoundsException

When the pointer position is invalid or the supplied length is negative

Return values
string

reset()

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


        
On this page

Search results