class EventBuffer (View source)

EventBuffer.

EventBuffer represents Libevent's "evbuffer", an utility functionality for buffered I/O. Event buffers are meant to be generally useful for doing the "buffer" part of buffered network I/O.

Constants

EOL_ANY

EOL_CRLF

EOL_CRLF_STRICT

EOL_LF

EOL_NUL

PTR_SET

PTR_ADD

Properties

int $length
int $contiguous_space

Methods

__construct()

__construct.

bool
add(string $data)

add.

bool
addBuffer(EventBuffer $buf)

addBuffer.

int
appendFrom(EventBuffer $buf, int $len)

appendFrom.

int
copyout(string $data, int $max_bytes)

copyout.

bool
drain(int $len)

drain.

void
enableLocking()

enableLocking.

bool
expand(int $len)

expand.

bool
freeze(bool $at_front)

freeze.

void
lock()

lock.

bool
prepend(string $data)

prepend.

bool
prependBuffer(EventBuffer $buf)

prependBuffer.

string|null
pullup(int $size)

pullup.

string|null
read(int $max_bytes)

read.

int
readFrom(mixed $fd, int $howmuch)

readFrom.

string|null
readLine(int $eol_style)

readLine.

int|false
search(string $what, int $start = 1, int $end = 1)

search.

int|false
searchEol(int $start = 1, int $eol_style = EventBuffer::EOL_ANY)

searchEol.

string
substr(int $start, int $length)

substr.

bool
unfreeze(bool $at_front)

unfreeze.

void
unlock()

unlock.

int|false
write(mixed $fd, int $howmuch)

write.

Details

__construct()

__construct.

Constructs EventBuffer object.

bool add(string $data)

add.

Append data to the end of an event buffer.

Parameters

string $data

Return Value

bool

See also

https://php.net/manual/en/eventbuffer.add.php

bool addBuffer(EventBuffer $buf)

addBuffer.

Move all data from a buffer provided to the current instance of EventBuffer.

Parameters

EventBuffer $buf

Return Value

bool

See also

https://php.net/manual/en/eventbuffer.addbuffer.php

int appendFrom(EventBuffer $buf, int $len)

appendFrom.

Moves the specified number of bytes from a source buffer to the end of the current buffer.

Parameters

EventBuffer $buf
int $len

Return Value

int

See also

https://php.net/manual/en/eventbuffer.appendfrom.php

int copyout(string $data, int $max_bytes)

copyout.

Copies out specified number of bytes from the front of the buffer.

Parameters

string $data
int $max_bytes

Return Value

int

See also

https://php.net/manual/en/eventbuffer.copyout.php

bool drain(int $len)

drain.

Removes specified number of bytes from the front of the buffer without copying it anywhere.

Parameters

int $len

Return Value

bool

See also

https://php.net/manual/en/eventbuffer.drain.php

void enableLocking()

enableLocking.

bool expand(int $len)

expand.

Reserves space in buffer.

Parameters

int $len

Return Value

bool

See also

https://php.net/manual/en/eventbuffer.expand.php

bool freeze(bool $at_front)

freeze.

Prevent calls that modify an event buffer from succeeding.

Parameters

bool $at_front

Return Value

bool

See also

https://php.net/manual/en/eventbuffer.freeze.php

void lock()

lock.

Acquires a lock on buffer.

bool prepend(string $data)

prepend.

Prepend data to the front of the buffer.

Parameters

string $data

Return Value

bool

See also

https://php.net/manual/en/eventbuffer.prepend.php

bool prependBuffer(EventBuffer $buf)

prependBuffer.

Moves all data from source buffer to the front of current buffer.

Parameters

EventBuffer $buf

Return Value

bool

See also

https://php.net/manual/en/eventbuffer.prependbuffer.php

string|null pullup(int $size)

pullup.

Linearizes data within buffer and returns it's contents as a string.

Parameters

int $size

Return Value

string|null

See also

https://php.net/manual/en/eventbuffer.pullup.php

string|null read(int $max_bytes)

read.

Read data from an evbuffer and drain the bytes read.

Parameters

int $max_bytes

Return Value

string|null

| string

int readFrom(mixed $fd, int $howmuch)

readFrom.

Read data from a file onto the end of the buffer.

Parameters

mixed $fd
int $howmuch

Return Value

int

See also

https://php.net/manual/en/eventbuffer.readfrom.php

string|null readLine(int $eol_style)

readLine.

Extracts a line from the front of the buffer.

Parameters

int $eol_style

Return Value

string|null

| string

See also

https://php.net/manual/en/eventbuffer.readline.php

search.

Scans the buffer for an occurrence of a string.

Parameters

string $what
int $start

= 1

int $end

= 1

Return Value

int|false

See also

https://php.net/manual/en/eventbuffer.search.php

int|false searchEol(int $start = 1, int $eol_style = EventBuffer::EOL_ANY)

searchEol.

Scans the buffer for an occurrence of an end of line.

Parameters

int $start

= 1

int $eol_style

= EOL_ANY

Return Value

int|false

See also

https://php.net/manual/en/eventbuffer.searcheol.php

string substr(int $start, int $length)

substr.

Substracts a portion of the buffer data.

Parameters

int $start
int $length (optional)

Return Value

string

See also

https://php.net/manual/en/eventbuffer.substr.php

bool unfreeze(bool $at_front)

unfreeze.

Re-enable calls that modify an event buffer.

Parameters

bool $at_front

Return Value

bool

See also

https://php.net/manual/en/eventbuffer.unfreeze.php

void unlock()

unlock.

Releases lock acquired by EventBuffer::lock.

int|false write(mixed $fd, int $howmuch)

write.

Write contents of the buffer to a file or socket.

Parameters

mixed $fd
int $howmuch (optional)

Return Value

int|false

See also

https://php.net/manual/en/eventbuffer.write.php