The EventBuffer class

(PECL event >= 1.5.0)

Introduction

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.

Class synopsis

classEventBuffer {
constintEOL_ANY = 0;
constintEOL_CRLF = 1;
constintEOL_LF = 3;
constintPTR_SET = 0;
constintPTR_ADD = 1;
publicreadonlyint$length;
publicreadonlyint$contiguous_space;
publicadd(string$data): bool
publicappendFrom(EventBuffer$buf, int$len): int
public__construct()
publiccopyout(string&$data, int$max_bytes): int
publicdrain(int$len): bool
publicexpand(int$len): bool
publicfreeze(bool$at_front): bool
publiclock(): void
publicprepend(string$data): bool
publicpullup(int$size): string
publicread(int$max_bytes): string
publicread(mixed$fd, int$howmuch): int
publicreadLine(int$eol_style): string
publicsearch(string$what, int$start = -1, int$end = -1): mixed
publicsearchEol(int$start = -1, int$eol_style = EventBuffer::EOL_ANY): mixed
publicsubstr(int$start, int$length = ?): string
publicunfreeze(bool$at_front): bool
publicunlock(): bool
publicwrite(mixed$fd, int$howmuch = ?): int
}

Properties

length

The number of bytes stored in an event buffer.

contiguous_space

The number of bytes stored contiguously at the front of the buffer. The bytes in a buffer may be stored in multiple separate chunks of memory; the property returns the number of bytes currently stored in the first chunk.

Predefined Constants

EventBuffer::EOL_ANY

The end of line is any sequence of any number of carriage return and linefeed characters. This format is not very useful; it exists mainly for backward compatibility.

EventBuffer::EOL_CRLF

The end of the line is an optional carriage return, followed by a linefeed. (In other words, it is either a "\r\n" or a "\n" .) This format is useful in parsing text-based Internet protocols, since the standards generally prescribe a "\r\n" line-terminator, but nonconformant clients sometimes say just "\n" .

EventBuffer::EOL_CRLF_STRICT

The end of a line is a single carriage return, followed by a single linefeed. (This is also known as "\r\n" . The ASCII values are 0x0D0x0A ).

EventBuffer::EOL_LF

The end of a line is a single linefeed character. (This is also known as "\n" . It is ASCII value is 0x0A .)

EventBuffer::PTR_SET

Flag used as argument of EventBuffer::setPosition() method. If this flag specified, the position pointer is moved to an absolute position within the buffer.

EventBuffer::PTR_ADD

The same as EventBuffer::PTR_SET , except this flag causes EventBuffer::setPosition() method to move position forward up to the specified number of bytes(instead of setting absolute position).

Table of Contents

To Top