在线文档教程
PHP
事件 | Event

EventBuffer (class)

The EventBuffer class

Introduction

(PECL event >= 1.5.0)

EventBuffer表示Libevent的“evbuffer”,一种缓冲I / O的实用功能。

事件缓冲区通常用于执行缓冲网络I / O的“缓冲区”部分。

课程简介

EventBuffer {

/* Constants */

const integer EOL_ANY = 0 ;

const integer EOL_CRLF = 1 ;

const integer EOL_CRLF_STRICT = 2 ;

const integer EOL_LF = 3 ;

const integer PTR_SET = 0 ;

const integer PTR_ADD = 1 ;

/* Properties */

public readonly int $length ;

public readonly int $contiguous_space ;

/* Methods */

public bool add ( string $data )

public bool addBuffer ( EventBuffer $buf )

public int appendFrom ( EventBuffer $buf , int $len )

public __construct ( void )

public int copyout ( string &$data , int $max_bytes )

public bool drain ( int $len )

public void enableLocking ( void )

public bool expand ( int $len )

public bool freeze ( bool $at_front )

public void lock ( void )

public bool prepend ( string $data )

public bool prependBuffer ( EventBuffer $buf )

public string pullup ( int $size )

public string read ( int $max_bytes )

public int read ( mixed $fd , int $howmuch )

public string readLine ( int $eol_style )

public mixed search ( string $what [, int $start = -1 [, int $end = -1 ]] )

public mixed searchEol ([ int $start = -1 [, int $eol_style = EventBuffer::EOL_ANY ]] )

public string substr ( int $start [, int $length ] )

public bool unfreeze ( bool $at_front )

public bool unlock ( void )

public int write ( mixed $fd [, int $howmuch ] )

}

属性

长度

存储在事件缓冲区中的字节数。

contiguous_space

连续存储在缓冲区前端的字节数。缓冲区中的字节可以存储在多个单独的内存块中; 该属性返回当前存储在第一个块中的字节数。

预定义的常量

EventBuffer::EOL_ANY

行尾是任意数量的回车和换行符的序列。这种格式不是很有用; 它主要用于向后兼容。

EventBuffer::EOL_CRLF

该行的结尾是一个可选的回车符,后跟一个换行符。(换句话说,它是“\ r \ n”“\ n”)。这种格式在解析基于文本的Internet协议时很有用,因为标准通常会规定一个“\ r \ n”行结束符,但不合格的客户有时会说“\ n”

EventBuffer::EOL_CRLF_STRICT

一行的结尾是单个回车符,后跟一个换行符。(这也被称为“\ r \ n”。ASCII值是)。0x0D 0x0A

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

用作EventBuffer :: setPosition()方法参数的标志。如果指定了此标志,则位置指针将移至缓冲区内的绝对位置。

EventBuffer::PTR_ADD

与此相同EventBuffer::PTR_SET,除了此标志导致EventBuffer :: setPosition()方法将位置向前移动到指定的字节数(而不是设置绝对位置)。

目录

  • EventBuffer::add — Append data to the end of an event buffer

  • EventBuffer::addBuffer — Move all data from a buffer provided to the current instance of EventBuffer

  • EventBuffer::appendFrom — Moves the specified number of bytes from a source buffer to the end of the current buffer

  • EventBuffer::__construct — Constructs EventBuffer object

  • EventBuffer::copyout — Copies out specified number of bytes from the front of the buffer

  • EventBuffer::drain — Removes specified number of bytes from the front of the buffer without copying it anywhere

  • EventBuffer::enableLocking — Description

  • EventBuffer::expand — Reserves space in buffer

  • EventBuffer::freeze — Prevent calls that modify an event buffer from succeeding

  • EventBuffer::lock — Acquires a lock on buffer

  • EventBuffer::prepend — Prepend data to the front of the buffer

  • EventBuffer::prependBuffer — Moves all data from source buffer to the front of current buffer

  • EventBuffer::pullup — Linearizes data within buffer and returns it's contents as a string

  • EventBuffer::readFrom — Read data from a file onto the end of the buffer

  • EventBuffer::readLine — Extracts a line from the front of the buffer

  • EventBuffer::searchEol — Scans the buffer for an occurrence of an end of line

  • EventBuffer::substr — Substracts a portion of the buffer data

  • EventBuffer::unfreeze — Re-enable calls that modify an event buffer

  • EventBuffer::unlock — Releases lock acquired by EventBuffer::lock

  • EventBuffer::write — Write contents of the buffer to a file or socket

← EventBase::stop

EventBuffer::add →