首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

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 */

代码语言:javascript
复制
public bool add (  string $data  )
代码语言:javascript
复制
public bool addBuffer (  EventBuffer $buf  )
代码语言:javascript
复制
public int appendFrom (  EventBuffer $buf  ,  int $len  )
代码语言:javascript
复制
public __construct ( void )
代码语言:javascript
复制
public int copyout (  string &$data  ,  int $max_bytes  )
代码语言:javascript
复制
public bool drain (  int $len  )
代码语言:javascript
复制
public void enableLocking ( void )
代码语言:javascript
复制
public bool expand (  int $len  )
代码语言:javascript
复制
public bool freeze (  bool $at_front  )
代码语言:javascript
复制
public void lock ( void )
代码语言:javascript
复制
public bool prepend (  string $data  )
代码语言:javascript
复制
public bool prependBuffer (  EventBuffer $buf  )
代码语言:javascript
复制
public string pullup (  int $size  )
代码语言:javascript
复制
public string read (  int $max_bytes  )
代码语言:javascript
复制
public int read (  mixed $fd  ,  int $howmuch  )
代码语言:javascript
复制
public string readLine (  int $eol_style  )
代码语言:javascript
复制
public mixed search (  string $what  [,  int $start  = -1  [,  int $end  = -1  ]] )
代码语言:javascript
复制
public mixed searchEol ([  int $start  = -1  [,  int $eol_style  = EventBuffer::EOL_ANY   ]] )
代码语言:javascript
复制
public string substr (  int $start  [,  int $length  ] )
代码语言:javascript
复制
public bool unfreeze (  bool $at_front  )
代码语言:javascript
复制
public bool unlock ( void )
代码语言:javascript
复制
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 →

扫码关注腾讯云开发者

领取腾讯云代金券