# Event

# 简介

这是适用于特定平台的最佳 I/O 通知机制，使用基于事件的调度 I/O、时间和信号的扩展。这是 PHP 基础设施的 libevent 移植。

> 注意:

> 注意，在 `event-1.9.0` 中引入对 Windows 的支持。

版本 1.0.0 引入了新的面向对象 API（打破了向下兼容性），并支持包含 HTTP、DNS、OpenSSL 和事件监听器的 libevent 2+。

> 注意:

> 注意，`event-1.0.0` 及其以后的版本不兼容之前的版本。

- 安装/配置
  - 需求
  - 安装
- 示例
- Event flags
- About event persistence
- Event callbacks
- Constructing signal events
- Event — The Event class
  - Event::add — Makes event pending
  - Event::addSignal — 别名 Event::add
  - Event::addTimer — 别名 Event::add
  - Event::__construct — Constructs Event object
  - Event::del — Makes event non-pending
  - Event::delSignal — 别名 Event::del
  - Event::delTimer — 别名 Event::del
  - Event::free — Make event non-pending and free resources allocated for this event
  - Event::getSupportedMethods — Returns array of the names of the methods supported in this version of Libevent
  - Event::pending — Detects whether event is pending or scheduled
  - Event::set — Re-configures event
  - Event::setPriority — Set event priority
  - Event::setTimer — Re-configures timer event
  - Event::signal — Constructs signal event object
  - Event::timer — Constructs timer event object
- EventBase — The EventBase class
  - EventBase::__construct — 构造 EventBase 对象
  - EventBase::dispatch — Dispatch pending events
  - EventBase::exit — Stop dispatching events
  - EventBase::free — Free resources allocated for this event base
  - EventBase::getFeatures — Returns bitmask of features supported
  - EventBase::getMethod — Returns event method in use
  - EventBase::getTimeOfDayCached — Returns the current event base time
  - EventBase::gotExit — Checks if the event loop was told to exit
  - EventBase::gotStop — Checks if the event loop was told to exit
  - EventBase::loop — Dispatch pending events
  - EventBase::priorityInit — Sets number of priorities per event base
  - EventBase::reInit — Re-initialize event base(after a fork)
  - EventBase::stop — Tells event_base to stop dispatching events
- EventBuffer — The EventBuffer class
  - 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 — 说明
  - 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 its contents as a string
  - EventBuffer::read — Read data from an evbuffer and drain the bytes read
  - 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::search — Scans the buffer for an occurrence of a string
  - EventBuffer::searchEol — Scans the buffer for an occurrence of an end of line
  - EventBuffer::substr — Subtracts 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
- EventBufferEvent — The EventBufferEvent class
  - EventBufferEvent::close — Closes file descriptor associated with the current buffer event
  - EventBufferEvent::connect — Connect buffer event's file descriptor to given address or UNIX socket
  - EventBufferEvent::connectHost — Connects to a hostname with optionally asynchronous DNS resolving
  - EventBufferEvent::__construct — Constructs EventBufferEvent object
  - EventBufferEvent::createPair — Creates two buffer events connected to each other
  - EventBufferEvent::disable — Disable events read, write, or both on a buffer event
  - EventBufferEvent::enable — Enable events read, write, or both on a buffer event
  - EventBufferEvent::free — Free a buffer event
  - EventBufferEvent::getDnsErrorString — Returns string describing the last failed DNS lookup attempt
  - EventBufferEvent::getEnabled — Returns bitmask of events currently enabled on the buffer event
  - EventBufferEvent::getInput — Returns underlying input buffer associated with current buffer event
  - EventBufferEvent::getOutput — Returns underlying output buffer associated with current buffer event
  - EventBufferEvent::read — Read buffer's data
  - EventBufferEvent::readBuffer — Drains the entire contents of the input buffer and places them into buf
  - EventBufferEvent::setCallbacks — Assigns read, write and event(status) callbacks
  - EventBufferEvent::setPriority — Assign a priority to a bufferevent
  - EventBufferEvent::setTimeouts — Set the read and write timeout for a buffer event
  - EventBufferEvent::setWatermark — Adjusts read and/or write watermarks
  - EventBufferEvent::sslError — Returns most recent OpenSSL error reported on the buffer event
  - EventBufferEvent::sslFilter — Create a new SSL buffer event to send its data over another buffer event
  - EventBufferEvent::sslGetCipherInfo — Returns a textual description of the cipher
  - EventBufferEvent::sslGetCipherName — Returns the current cipher name of the SSL connection
  - EventBufferEvent::sslGetCipherVersion — Returns version of cipher used by current SSL connection
  - EventBufferEvent::sslGetProtocol — Returns the name of the protocol used for current SSL connection
  - EventBufferEvent::sslRenegotiate — Tells a bufferevent to begin SSL renegotiation
  - EventBufferEvent::sslSocket — Creates a new SSL buffer event to send its data over an SSL on a socket
  - EventBufferEvent::write — Adds data to a buffer event's output buffer
  - EventBufferEvent::writeBuffer — Adds contents of the entire buffer to a buffer event's output buffer
- About buffer event callbacks
- EventConfig — EventConfig 类
  - EventConfig::avoidMethod — 告诉 libevent 避免使用指定 event 方法
  - EventConfig::__construct — EventConfig 构造函数
  - EventConfig::requireFeatures — 输入应用程序要求的必需 event 方法功能
  - EventConfig::setFlags — EventBase 初始化需设置的一个或者多个 flag
  - EventConfig::setMaxDispatchInterval — 防止优先级反转
- EventDnsBase — The EventDnsBase class
  - EventDnsBase::addNameserverIp — Adds a nameserver to the DNS base
  - EventDnsBase::addSearch — Adds a domain to the list of search domains
  - EventDnsBase::clearSearch — Removes all current search suffixes
  - EventDnsBase::__construct — Constructs EventDnsBase object
  - EventDnsBase::countNameservers — Gets the number of configured nameservers
  - EventDnsBase::loadHosts — Loads a hosts file (in the same format as /etc/hosts) from hosts file
  - EventDnsBase::parseResolvConf — Scans the resolv.conf-formatted file
  - EventDnsBase::setOption — Set the value of a configuration option
  - EventDnsBase::setSearchNdots — Set the 'ndots' parameter for searches
- EventHttp — The EventHttp class
  - EventHttp::accept — Makes an HTTP server accept connections on the specified socket stream or resource
  - EventHttp::addServerAlias — Adds a server alias to the HTTP server object
  - EventHttp::bind — Binds an HTTP server on the specified address and port
  - EventHttp::__construct — Constructs EventHttp object (the HTTP server)
  - EventHttp::removeServerAlias — Removes server alias
  - EventHttp::setAllowedMethods — Sets which HTTP methods are supported in requests accepted by this server, and passed to user callbacks
  - EventHttp::setCallback — Sets a callback for specified URI
  - EventHttp::setDefaultCallback — Sets default callback to handle requests that are not caught by specific callbacks
  - EventHttp::setMaxBodySize — Sets maximum request body size
  - EventHttp::setMaxHeadersSize — Sets maximum HTTP header size
  - EventHttp::setTimeout — Sets the timeout for an HTTP request
- EventHttpConnection — The EventHttpConnection class
  - EventHttpConnection::__construct — Constructs EventHttpConnection object
  - EventHttpConnection::getBase — Returns event base associated with the connection
  - EventHttpConnection::getPeer — Gets the remote address and port associated with the connection
  - EventHttpConnection::makeRequest — Makes an HTTP request over the specified connection
  - EventHttpConnection::setCloseCallback — Set callback for connection close
  - EventHttpConnection::setLocalAddress — Sets the IP address from which HTTP connections are made
  - EventHttpConnection::setLocalPort — Sets the local port from which connections are made
  - EventHttpConnection::setMaxBodySize — Sets maximum body size for the connection
  - EventHttpConnection::setMaxHeadersSize — Sets maximum header size
  - EventHttpConnection::setRetries — Sets the retry limit for the connection
  - EventHttpConnection::setTimeout — Sets the timeout for the connection
- EventHttpRequest — The EventHttpRequest class
  - EventHttpRequest::addHeader — Adds an HTTP header to the headers of the request
  - EventHttpRequest::cancel — Cancels a pending HTTP request
  - EventHttpRequest::clearHeaders — Removes all output headers from the header list of the request
  - EventHttpRequest::closeConnection — Closes associated HTTP connection
  - EventHttpRequest::__construct — Constructs EventHttpRequest object
  - EventHttpRequest::findHeader — Finds the value belonging to a header
  - EventHttpRequest::free — Frees the object and removes associated events
  - EventHttpRequest::getBufferEvent — Returns EventBufferEvent object
  - EventHttpRequest::getCommand — Returns the request command(method)
  - EventHttpRequest::getConnection — Returns EventHttpConnection object
  - EventHttpRequest::getHost — Returns the request host
  - EventHttpRequest::getInputBuffer — Returns the input buffer
  - EventHttpRequest::getInputHeaders — Returns associative array of the input headers
  - EventHttpRequest::getOutputBuffer — Returns the output buffer of the request
  - EventHttpRequest::getOutputHeaders — Returns associative array of the output headers
  - EventHttpRequest::getResponseCode — Returns the response code
  - EventHttpRequest::getUri — Returns the request URI
  - EventHttpRequest::removeHeader — Removes an HTTP header from the headers of the request
  - EventHttpRequest::sendError — Send an HTML error message to the client
  - EventHttpRequest::sendReply — Send an HTML reply to the client
  - EventHttpRequest::sendReplyChunk — Send another data chunk as part of an ongoing chunked reply
  - EventHttpRequest::sendReplyEnd — Complete a chunked reply, freeing the request as appropriate
  - EventHttpRequest::sendReplyStart — Initiate a chunked reply
- EventListener — The EventListener class
  - EventListener::__construct — Creates new connection listener associated with an event base
  - EventListener::disable — Disables an event connect listener object
  - EventListener::enable — Enables an event connect listener object
  - EventListener::getBase — Returns event base associated with the event listener
  - EventListener::getSocketName — Retrieves the current address to which the listener's socket is bound
  - EventListener::setCallback — The setCallback purpose
  - EventListener::setErrorCallback — Set event listener's error callback
- EventSslContext — The EventSslContext class
  - EventSslContext::__construct — Constructs an OpenSSL context for use with Event classes
- EventUtil — The EventUtil class
  - EventUtil::__construct — The abstract constructor
  - EventUtil::getLastSocketErrno — Returns the most recent socket error number
  - EventUtil::getLastSocketError — Returns the most recent socket error
  - EventUtil::getSocketFd — Returns numeric file descriptor of a socket, or stream
  - EventUtil::getSocketName — Retrieves the current address to which the socket is bound
  - EventUtil::setSocketOption — Sets socket options
  - EventUtil::sslRandPoll — Generates entropy by means of OpenSSL's RAND_poll()
- EventException — The EventException class

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open