Event

目次

The Event class

はじめに

Event class represents and event firing on a file descriptor being ready to read from or write to; a file descriptor becoming ready to read from or write to(edge-triggered I/O only); a timeout expiring; a signal occurring; a user-triggered event.

Every event is associated with EventBase . However, event will never fire until it is added (via Event::add ). An added event remains in pending state until the registered event occurs, thus turning it to active state. To handle events user may register a callback which is called when event becomes active. If event is configured persistent , it remains pending. If it is not persistent, it stops being pending when it's callback runs. Event::del method deletes event, thus making it non-pending. By means of Event::add method it could be added again.

クラス概要

Event
final class Event {
/* 定数 */
const int Event::ET = 32;
const int Event::PERSIST = 16;
const int Event::READ = 2;
const int Event::WRITE = 4;
const int Event::SIGNAL = 8;
const int Event::TIMEOUT = 1;
/* プロパティ */
public readonly bool $pending;
/* メソッド */
public bool add( float $timeout = ?)
public __construct(
     EventBase $base ,
     mixed $fd ,
     int $what ,
     callable $cb ,
     mixed $arg = NULL
)
public bool del()
public void free()
public static array getSupportedMethods()
public bool pending( int $flags )
public bool set(
     EventBase $base ,
     mixed $fd ,
     int $what = ?,
     callable $cb = ?,
     mixed $arg = ?
)
public bool setPriority( int $priority )
public bool setTimer( EventBase $base , callable $cb , mixed $arg = ?)
public static Event signal(
     EventBase $base ,
     int $signum ,
     callable $cb ,
     mixed $arg = ?
)
public static Event timer( EventBase $base , callable $cb , mixed $arg = ?)
}

プロパティ

pending

Whether event is pending. See About event persistence .

定義済み定数

Event::ET

Indicates that the event should be edge-triggered, if the underlying event base backend supports edge-triggered events. This affects the semantics of Event::READ and Event::WRITE .

Event::PERSIST

Indicates that the event is persistent. See About event persistence .

Event::READ

This flag indicates an event that becomes active when the provided file descriptor(usually a stream resource, or socket) is ready for reading.

Event::WRITE

This flag indicates an event that becomes active when the provided file descriptor(usually a stream resource, or socket) is ready for reading.

Event::SIGNAL

Used to implement signal detection. See "Constructing signal events" below.

Event::TIMEOUT

This flag indicates an event that becomes active after a timeout elapses.

The Event::TIMEOUT flag is ignored when constructing an event: one can either set a timeout when event is added , or not. It is set in the $what argument to the callback function when a timeout has occurred.

The EventBase class

はじめに

EventBase class represents libevent's event base structure. It holds a set of events and can poll to determine which events are active.

Each event base has a method , or a backend that it uses to determine which events are ready. The recognized methods are: select , poll , epoll , kqueue , devpoll , evport and win32 .

To configure event base to use, or avoid specific backend EventConfig class can be used.

警告

Do NOT destroy the EventBase object as long as resources of the associated Event objects are not released. Otherwise, it will lead to unpredictable results!

クラス概要

EventBase
final class EventBase {
/* 定数 */
const int EventBase::LOOP_ONCE = 1;
const int EventBase::LOOP_NONBLOCK = 2;
const int EventBase::NOLOCK = 1;
const int EventBase::STARTUP_IOCP = 4;
const int EventBase::NO_CACHE_TIME = 8;
const int EventBase::EPOLL_USE_CHANGELIST = 16;
/* メソッド */
public __construct( EventConfig $cfg = ?)
public void dispatch()
public bool exit( float $timeout = ?)
public void free()
public int getFeatures()
public string getMethod()
public float getTimeOfDayCached()
public bool gotExit()
public bool gotStop()
public bool loop( int $flags = ?)
public bool priorityInit( int $n_priorities )
public bool reInit()
public bool stop()
}

定義済み定数

EventBase::LOOP_ONCE

Flag used with EventBase::loop method which means: "block until libevent has an active event, then exit once all active events have had their callbacks run".

EventBase::LOOP_NONBLOCK

Flag used with EventBase::loop method which means: "do not block: see which events are ready now, run the callbacks of the highest-priority ones, then exit".

EventBase::NOLOCK

Configuration flag. Do not allocate a lock for the event base, even if we have locking set up".

EventBase::STARTUP_IOCP

Windows-only configuration flag. Enables the IOCP dispatcher at startup.

EventBase::NO_CACHE_TIME

Configuration flag. Instead of checking the current time every time the event loop is ready to run timeout callbacks, check after each timeout callback.

EventBase::EPOLL_USE_CHANGELIST

If we are using the epoll backend, this flag says that it is safe to use Libevent's internal change-list code to batch up adds and deletes in order to try to do as few syscalls as possible.

Setting this flag can make code run faster, but it may trigger a Linux bug: it is not safe to use this flag if one has any fds cloned by dup(), or its variants. Doing so will produce strange and hard-to-diagnose bugs.

This flag can also be activated by settnig the EVENT_EPOLL_USE_CHANGELIST environment variable.

This flag has no effect if one winds up using a backend other than epoll .

The EventBuffer class

はじめに

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.

クラス概要

EventBuffer
class EventBuffer {
/* 定数 */
const int EventBuffer::EOL_ANY = 0;
const int EventBuffer::EOL_CRLF = 1;
const int EventBuffer::EOL_CRLF_STRICT = 2;
const int EventBuffer::EOL_LF = 3;
const int EventBuffer::PTR_SET = 0;
const int EventBuffer::PTR_ADD = 1;
/* プロパティ */
public readonly int $length;
public readonly int $contiguous_space;
/* メソッド */
public bool add( string $data )
public bool addBuffer( EventBuffer $buf )
public int appendFrom( EventBuffer $buf , int $len )
public __construct()
public int copyout( string &$data , int $max_bytes )
public bool drain( int $len )
public void enableLocking()
public bool expand( int $len )
public bool freeze( bool $at_front )
public void lock()
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()
public int write( mixed $fd , int $howmuch = ?)
}

プロパティ

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.

定義済み定数

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

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).

The EventBufferEvent class

はじめに

Represents Libevent's buffer event.

Usually an application wants to perform some amount of data buffering in addition to just responding to events. When we want to write data, for example, the usual pattern looks like:

  1. Decide that we want to write some data to a connection; put that data in a buffer.

  2. Wait for the connection to become writable

  3. Write as much of the data as we can

  4. Remember how much we wrote, and if we still have more data to write, wait for the connection to become writable again.

This buffered I/O pattern is common enough that Libevent provides a generic mechanism for it. A "buffer event" consists of an underlying transport (like a socket), a read buffer, and a write buffer. Instead of regular events, which give callbacks when the underlying transport is ready to be read or written, a buffer event invokes its user-supplied callbacks when it has read or written enough data.

クラス概要

EventBufferEvent
final class EventBufferEvent {
/* 定数 */
const int EventBufferEvent::READING = 1;
const int EventBufferEvent::WRITING = 2;
const int EventBufferEvent::EOF = 16;
const int EventBufferEvent::ERROR = 32;
const int EventBufferEvent::TIMEOUT = 64;
const int EventBufferEvent::CONNECTED = 128;
const int EventBufferEvent::OPT_CLOSE_ON_FREE = 1;
const int EventBufferEvent::OPT_THREADSAFE = 2;
const int EventBufferEvent::OPT_DEFER_CALLBACKS = 4;
const int EventBufferEvent::OPT_UNLOCK_CALLBACKS = 8;
const int EventBufferEvent::SSL_OPEN = 0;
const int EventBufferEvent::SSL_CONNECTING = 1;
const int EventBufferEvent::SSL_ACCEPTING = 2;
/* プロパティ */
public int $fd;
public int $priority;
public readonly EventBuffer $input;
public readonly EventBuffer $output;
/* メソッド */
public void close()
public bool connect( string $addr )
public bool connectHost(
     EventDnsBase $dns_base ,
     string $hostname ,
     int $port ,
     int $family = EventUtil::AF_UNSPEC
)
public __construct(
     EventBase $base ,
     mixed $socket = null ,
     int $options = 0 ,
     callable $readcb = null ,
     callable $writecb = null ,
     callable $eventcb = null ,
     mixed $arg = null
)
public static array createPair( EventBase $base , int $options = 0 )
public bool disable( int $events )
public bool enable( int $events )
public void free()
public string getDnsErrorString()
public int getEnabled()
public EventBuffer getInput()
public EventBuffer getOutput()
public string read( int $size )
public bool readBuffer( EventBuffer $buf )
public void setCallbacks(
     callable $readcb ,
     callable $writecb ,
     callable $eventcb ,
     mixed $arg = ?
)
public bool setPriority( int $priority )
public bool setTimeouts( float $timeout_read , float $timeout_write )
public void setWatermark( int $events , int $lowmark , int $highmark )
public string sslError()
public static EventBufferEvent sslFilter(
     EventBase $base ,
     EventBufferEvent $underlying ,
     EventSslContext $ctx ,
     int $state ,
     int $options = 0
)
public string sslGetCipherInfo()
public string sslGetCipherName()
public string sslGetCipherVersion()
public string sslGetProtocol()
public void sslRenegotiate()
public static EventBufferEvent sslSocket(
     EventBase $base ,
     mixed $socket ,
     EventSslContext $ctx ,
     int $state ,
     int $options = ?
)
public bool write( string $data )
public bool writeBuffer( EventBuffer $buf )
}

プロパティ

fd

Numeric file descriptor associated with the buffer event. Normally represents a bound socket. Equals to null, if there is no file descriptor(socket) associated with the buffer event.

priority

The priority of the events used to implement the buffer event.

input

Underlying input buffer object( EventBuffer )

output

Underlying output buffer object( EventBuffer )

定義済み定数

EventBufferEvent::READING

An event occurred during a read operation on the bufferevent. See the other flags for which event it was.

EventBufferEvent::WRITING

An event occurred during a write operation on the bufferevent. See the other flags for which event it was.

EventBufferEvent::EOF

Got an end-of-file indication on the buffer event.

EventBufferEvent::ERROR

An error occurred during a bufferevent operation. For more information on what the error was, call EventUtil::getLastSocketErrno and/or EventUtil::getLastSocketError .

EventBufferEvent::TIMEOUT

EventBufferEvent::CONNECTED

Finished a requested connection on the bufferevent.

EventBufferEvent::OPT_CLOSE_ON_FREE

When the buffer event is freed, close the underlying transport. This will close an underlying socket, free an underlying buffer event, etc.

EventBufferEvent::OPT_THREADSAFE

Automatically allocate locks for the bufferevent, so that it’s safe to use from multiple threads.

EventBufferEvent::OPT_DEFER_CALLBACKS

When this flag is set, the bufferevent defers all of its callbacks. See » Fast portable non-blocking network programming with Libevent, Deferred callbacks .

EventBufferEvent::OPT_UNLOCK_CALLBACKS

By default, when the bufferevent is set up to be threadsafe, the buffer event’s locks are held whenever the any user-provided callback is invoked. Setting this option makes Libevent release the buffer event’s lock when it’s invoking the callbacks.

EventBufferEvent::SSL_OPEN

The SSL handshake is done

EventBufferEvent::SSL_CONNECTING

SSL is currently performing negotiation as a client

EventBufferEvent::SSL_ACCEPTING

SSL is currently performing negotiation as a server

The EventConfig class

はじめに

Represents configuration structure which could be used in construction of the EventBase .

クラス概要

EventConfig
final class EventConfig {
/* 定数 */
const int EventConfig::FEATURE_ET = 1;
const int EventConfig::FEATURE_O1 = 2;
const int EventConfig::FEATURE_FDS = 4;
/* メソッド */
public bool avoidMethod( string $method )
public __construct()
public bool requireFeatures( int $feature )
public bool setFlags( int $flags )
public void setMaxDispatchInterval( int $max_interval , int $max_callbacks , int $min_priority )
}

定義済み定数

EventConfig::FEATURE_ET

Requires a backend method that supports edge-triggered I/O.

EventConfig::FEATURE_O1

Requires a backend method where adding or deleting a single event, or having a single event become active, is an O(1) operation.

EventConfig::FEATURE_FDS

Requires a backend method that can support arbitrary file descriptor types, and not just sockets.

The EventDnsBase class

はじめに

Represents Libevent's DNS base structure. Used to resolve DNS asyncronously, parse configuration files like resolv.conf etc.

クラス概要

EventDnsBase
final class EventDnsBase {
/* 定数 */
const int EventDnsBase::OPTION_SEARCH = 1;
const int EventDnsBase::OPTION_NAMESERVERS = 2;
const int EventDnsBase::OPTION_MISC = 4;
const int EventDnsBase::OPTION_HOSTSFILE = 8;
const int EventDnsBase::OPTIONS_ALL = 15;
const int EventDnsBase::DISABLE_WHEN_INACTIVE = 32768;
const int EventDnsBase::INITIALIZE_NAMESERVERS = 1;
const int EventDnsBase::NAMESERVERS_NO_DEFAULT = 65536;
/* メソッド */
public __construct( EventBase $base , intbool $initialize )
public bool addNameserverIp( string $ip )
public void addSearch( string $domain )
public void clearSearch()
public int countNameservers()
public bool loadHosts( string $hosts )
public bool parseResolvConf( int $flags , string $filename )
public bool setOption( string $option , string $value )
public bool setSearchNdots( int $ndots )
}

定義済み定数

Tells to read the domain and search fields from the resolv.conf file and the ndots option, and use them to decide which domains(if any) to search for hostnames that aren’t fully-qualified.

EventDnsBase::OPTION_NAMESERVERS

Tells to learn the nameservers from the resolv.conf file.

EventDnsBase::OPTION_MISC

EventDnsBase::OPTION_HOSTSFILE

Tells to read a list of hosts from /etc/hosts as part of loading the resolv.conf file.

EventDnsBase::OPTIONS_ALL

Tells to learn as much as it can from the resolv.conf file.

EventDnsBase::DISABLE_WHEN_INACTIVE

Do not prevent the libevent event loop from exiting when we have no active DNS requests.

EventDnsBase::INITIALIZE_NAMESERVERS

Process the resolv.conf.

EventDnsBase::NAMESERVERS_NO_DEFAULT

Do not add default nameserver if there are no nameservers in the resolv.conf.

The EventHttp class

はじめに

Represents HTTP server.

クラス概要

EventHttp
final class EventHttp {
/* メソッド */
public bool accept( mixed $socket )
public bool addServerAlias( string $alias )
public void bind( string $address , int $port )
public __construct( EventBase $base , EventSslContext $ctx = null )
public bool removeServerAlias( string $alias )
public void setAllowedMethods( int $methods )
public void setCallback( string $path , string $cb , string $arg = ?)
public void setDefaultCallback( string $cb , string $arg = ?)
public void setMaxBodySize( int $value )
public void setMaxHeadersSize( int $value )
public void setTimeout( int $value )
}

The EventHttpConnection class

はじめに

Represents an HTTP connection.

クラス概要

EventHttpConnection
class EventHttpConnection {
/* メソッド */
public __construct(
     EventBase $base ,
     EventDnsBase $dns_base ,
     string $address ,
     int $port ,
     EventSslContext $ctx = null
)
public EventBase getBase()
public void getPeer( string &$address , int &$port )
public bool makeRequest( EventHttpRequest $req , int $type , string $uri )
public void setCloseCallback( callable $callback , mixed $data = ?)
public void setLocalAddress( string $address )
public void setLocalPort( int $port )
public void setMaxBodySize( string $max_size )
public void setMaxHeadersSize( string $max_size )
public void setRetries( int $retries )
public void setTimeout( int $timeout )
}

The EventHttpRequest class

はじめに

Represents an HTTP request.

クラス概要

EventHttpRequest
class EventHttpRequest {
/* 定数 */
const int EventHttpRequest::CMD_GET = 1;
const int EventHttpRequest::CMD_POST = 2;
const int EventHttpRequest::CMD_HEAD = 4;
const int EventHttpRequest::CMD_PUT = 8;
const int EventHttpRequest::CMD_DELETE = 16;
const int EventHttpRequest::CMD_OPTIONS = 32;
const int EventHttpRequest::CMD_TRACE = 64;
const int EventHttpRequest::CMD_CONNECT = 128;
const int EventHttpRequest::CMD_PATCH = 256;
const int EventHttpRequest::INPUT_HEADER = 1;
const int EventHttpRequest::OUTPUT_HEADER = 2;
/* メソッド */
public bool addHeader( string $key , string $value , int $type )
public void cancel()
public void clearHeaders()
public void closeConnection()
public __construct( callable $callback , mixed $data = null )
public void findHeader( string $key , string $type )
public void free()
public EventBufferEvent closeConnection()
public void getCommand()
public EventHttpConnection closeConnection()
public string getHost()
public EventBuffer getInputBuffer()
public array getInputHeaders()
public EventBuffer getOutputBuffer()
public void getOutputHeaders()
public int getResponseCode()
public string getUri()
public void removeHeader( string $key , string $type )
public void sendError( int $error , string $reason = null )
public void sendReply( int $code , string $reason , EventBuffer $buf = ?)
public void sendReplyChunk( EventBuffer $buf )
public void sendReplyEnd()
public void sendReplyStart( int $code , string $reason )
}

定義済み定数

EventHttpRequest::CMD_GET

GET method(command)

EventHttpRequest::CMD_POST

POST method(command)

EventHttpRequest::CMD_HEAD

HEAD method(command)

EventHttpRequest::CMD_PUT

PUT method(command)

EventHttpRequest::CMD_DELETE

DELETE command(method)

EventHttpRequest::CMD_OPTIONS

OPTIONS method(command)

EventHttpRequest::CMD_TRACE

TRACE method(command)

EventHttpRequest::CMD_CONNECT

CONNECT method(command)

EventHttpRequest::CMD_PATCH

PATCH method(command)

EventHttpRequest::INPUT_HEADER

Request input header type.

EventHttpRequest::OUTPUT_HEADER

Request output header type.

The EventListener class

はじめに

Represents a connection listener.

クラス概要

EventListener
final class EventListener {
/* 定数 */
const int EventListener::OPT_LEAVE_SOCKETS_BLOCKING = 1;
const int EventListener::OPT_CLOSE_ON_FREE = 2;
const int EventListener::OPT_CLOSE_ON_EXEC = 4;
const int EventListener::OPT_REUSEABLE = 8;
const int EventListener::OPT_THREADSAFE = 16;
/* プロパティ */
public readonly int $fd;
/* メソッド */
public __construct(
     EventBase $base ,
     callable $cb ,
     mixed $data ,
     int $flags ,
     int $backlog ,
     mixed $target
)
public bool disable()
public bool enable()
public void getBase()
public static bool getSocketName( string &$address , mixed &$port = ?)
public void setCallback( callable $cb , mixed $arg = null )
public void setErrorCallback( string $cb )
}

プロパティ

fd

Numeric file descriptor of the underlying socket. (Added in event-1.6.0 .)

定義済み定数

EventListener::OPT_LEAVE_SOCKETS_BLOCKING

By default Libevent turns underlying file descriptors, or sockets, to non-blocking mode. This flag tells Libevent to leave them in blocking mode.

EventListener::OPT_CLOSE_ON_FREE

If this option is set, the connection listener closes its underlying socket when the EventListener object is freed.

EventListener::OPT_CLOSE_ON_EXEC

If this option is set, the connection listener sets the close-on-exec flag on the underlying listener socket. See platform documentation for fcntl and FD_CLOEXEC for more information.

EventListener::OPT_REUSEABLE

By default on some platforms, once a listener socket is closed, no other socket can bind to the same port until a while has passed. Setting this option makes Libevent mark the socket as reusable, so that once it is closed, another socket can be opened to listen on the same port.

EventListener::OPT_THREADSAFE

Allocate locks for the listener, so that it’s safe to use it from multiple threads.

The EventSslContext class

はじめに

Represents SSL_CTX structure. Provides methods and properties to configure the SSL context.

クラス概要

EventSslContext
final class EventSslContext {
/* 定数 */
const int EventSslContext::SSLv2_CLIENT_METHOD = 1;
const int EventSslContext::SSLv3_CLIENT_METHOD = 2;
const int EventSslContext::SSLv23_CLIENT_METHOD = 3;
const int EventSslContext::TLS_CLIENT_METHOD = 4;
const int EventSslContext::SSLv2_SERVER_METHOD = 5;
const int EventSslContext::SSLv3_SERVER_METHOD = 6;
const int EventSslContext::SSLv23_SERVER_METHOD = 7;
const int EventSslContext::TLS_SERVER_METHOD = 8;
const int EventSslContext::OPT_LOCAL_CERT = 1;
const int EventSslContext::OPT_LOCAL_PK = 2;
const int EventSslContext::OPT_PASSPHRASE = 3;
const int EventSslContext::OPT_CA_FILE = 4;
const int EventSslContext::OPT_CA_PATH = 5;
const int EventSslContext::OPT_ALLOW_SELF_SIGNED = 6;
const int EventSslContext::OPT_VERIFY_PEER = 7;
const int EventSslContext::OPT_VERIFY_DEPTH = 8;
const int EventSslContext::OPT_CIPHERS = 9;
/* プロパティ */
public string $local_cert;
public string $local_pk;
/* メソッド */
public __construct( string $method , string $options )
}

プロパティ

local_cert

Path to local certificate file on filesystem. It must be a PEM-encoded file which contains certificate. It can optionally contain the certificate chain of issuers.

local_pk

Path to local private key file

定義済み定数

EventSslContext::SSLv2_CLIENT_METHOD

SSLv2 client method. See SSL_CTX_new(3) man page.

EventSslContext::SSLv3_CLIENT_METHOD

SSLv3 client method. See SSL_CTX_new(3) man page.

EventSslContext::SSLv23_CLIENT_METHOD

SSLv23 client method. See SSL_CTX_new(3) man page.

EventSslContext::TLS_CLIENT_METHOD

TLS client method. See SSL_CTX_new(3) man page.

EventSslContext::SSLv2_SERVER_METHOD

SSLv2 server method. See SSL_CTX_new(3) man page.

EventSslContext::SSLv3_SERVER_METHOD

SSLv3 server method. See SSL_CTX_new(3) man page.

EventSslContext::SSLv23_SERVER_METHOD

SSLv23 server method. See SSL_CTX_new(3) man page.

EventSslContext::TLS_SERVER_METHOD

TLS server method. See SSL_CTX_new(3) man page.

EventSslContext::OPT_LOCAL_CERT

Key for an item of the options' array used in EventSslContext::__construct . The option points to path of local certificate.

EventSslContext::OPT_LOCAL_PK

Key for an item of the options' array used in EventSslContext::__construct . The option points to path of the private key.

EventSslContext::OPT_PASSPHRASE

Key for an item of the options' array used in EventSslContext::__construct . Represents passphrase of the certificate.

EventSslContext::OPT_CA_FILE

Key for an item of the options' array used in EventSslContext::__construct . Represents path of the certificate authority file.

EventSslContext::OPT_CA_PATH

Key for an item of the options' array used in EventSslContext::__construct . Represents path where the certificate authority file should be searched for.

EventSslContext::OPT_ALLOW_SELF_SIGNED

Key for an item of the options' array used in EventSslContext::__construct . Represents option that allows self-signed certificates.

EventSslContext::OPT_VERIFY_PEER

Key for an item of the options' array used in EventSslContext::__construct . Represents option that tells Event to verify peer.

EventSslContext::OPT_VERIFY_DEPTH

Key for an item of the options' array used in EventSslContext::__construct . Represents maximum depth for the certificate chain verification that shall be allowed for the SSL context.

EventSslContext::OPT_CIPHERS

Key for an item of the options' array used in EventSslContext::__construct . Represents the cipher list for the SSL context.

The EventUtil class

はじめに

EventUtil is a singleton with supplimentary methods and constants.

クラス概要

EventUtil
final class EventUtil {
/* 定数 */
const int EventUtil::AF_INET = 2;
const int EventUtil::AF_INET6 = 10;
const int EventUtil::AF_UNSPEC = 0;
const int EventUtil::LIBEVENT_VERSION_NUMBER = 33559808;
const int EventUtil::SO_DEBUG = 1;
const int EventUtil::SO_REUSEADDR = 2;
const int EventUtil::SO_KEEPALIVE = 9;
const int EventUtil::SO_DONTROUTE = 5;
const int EventUtil::SO_LINGER = 13;
const int EventUtil::SO_BROADCAST = 6;
const int EventUtil::SO_OOBINLINE = 10;
const int EventUtil::SO_SNDBUF = 7;
const int EventUtil::SO_RCVBUF = 8;
const int EventUtil::SO_SNDLOWAT = 19;
const int EventUtil::SO_RCVLOWAT = 18;
const int EventUtil::SO_SNDTIMEO = 21;
const int EventUtil::SO_RCVTIMEO = 20;
const int EventUtil::SO_TYPE = 3;
const int EventUtil::SO_ERROR = 4;
const int EventUtil::SOL_SOCKET = 1;
const int EventUtil::SOL_TCP = 6;
const int EventUtil::SOL_UDP = 17;
const int EventUtil::IPPROTO_IP = 0;
const int EventUtil::IPPROTO_IPV6 = 41;
/* メソッド */
abstract public __construct()
public static int getLastSocketErrno( mixed $socket = null )
public static string getLastSocketError( mixed $socket = ?)
public static int getSocketFd( mixed $socket )
public static bool getSocketName( mixed $socket , string &$address , mixed &$port = ?)
public static bool setSocketOption(
     mixed $socket ,
     int $level ,
     int $optname ,
     mixed $optval
)
public static void sslRandPoll()
}

定義済み定数

EventUtil::AF_INET

IPv4 address family

EventUtil::AF_INET6

IPv6 address family

EventUtil::AF_UNSPEC

Unspecified IP address family

EventUtil::SO_DEBUG

Socket option. Enable socket debugging. Only allowed for processes with the CAP_NET_ADMIN capability or an effective user ID of 0 . (Added in event-1.6.0.)

EventUtil::SO_REUSEADDR

Socket option. Indicates that the rules used in validating addresses supplied in a bind(2) call should allow reuse of local addresses. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_KEEPALIVE

Socket option. Enable sending of keep-alive messages on connection-oriented sockets. Expects an integer boolean flag. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_DONTROUTE

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_LINGER

Socket option. When enabled, a close(2) or shutdown(2) will not return until all queued messages for the socket have been successfully sent or the linger timeout has been reached. Otherwise, the call returns immediately and the closing is done in the background. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_BROADCAST

Socket option. Reports whether transmission of broadcast messages is supported. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_OOBINLINE

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_SNDBUF

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_RCVBUF

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_SNDLOWAT

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_RCVLOWAT

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_SNDTIMEO

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_RCVTIMEO

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_TYPE

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SO_ERROR

Socket option. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SOL_SOCKET

Socket option level. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SOL_TCP

Socket option level. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::SOL_UDP

Socket option level. See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::IPPROTO_IP

See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::IPPROTO_IPV6

See the socket(7) manual page. (Added in event-1.6.0.)

EventUtil::LIBEVENT_VERSION_NUMBER

Libevent' version number at the time when Event extension had been compiled with the library.

The EventException class

はじめに

A EventException is thrown when the Event extension methods encounter invalid user input or identify an unrecoverable error. This exception serves as a signal for developers to handle exceptional situations gracefully.

クラス概要

EventException
extends RuntimeException
/* 継承したプロパティ */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private Throwablenull $previous = null;
/* 継承したメソッド */
public Error::__construct(string $message = "", int $code = 0, Throwablenull $previous = null)
final public string Error::getMessage()
final public Throwablenull Error::getPrevious()
final public int Error::getCode()
final public string Error::getFile()
final public int Error::getLine()
final public array Error::getTrace()
final public string Error::getTraceAsString()
public string Error::__toString()
private void Error::__clone()