EventTable of Contents
The Event classIntroductionEvent 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 occuring; 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. Class synopsis
Event
final
class Event
{
/* Constants */
const
integer
Event::ET
= 32
;
const
integer
Event::PERSIST
= 16
;
const
integer
Event::READ
= 2
;
const
integer
Event::WRITE
= 4
;
const
integer
Event::SIGNAL
= 8
;
const
integer
Event::TIMEOUT
= 1
;
/* Properties */
public
readonly
bool
$pending
;
/* Methods */
public
bool
add
([
double
$timeout
] )
public
bool
addSignal
([
double
$timeout
] )
public
bool
addTimer
([
double
$timeout
] )
public
__construct
(
EventBase
$base
,
mixed
$fd
,
int
$what
,
callable
$cb
[,
mixed
$arg
= NULL
] )
public
bool
del
( void
)
public
bool
delSignal
( void
)
public
bool
delTimer
( void
)
public
void
free
( void
)
public
static
array
getSupportedMethods
( void
)
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
] )Properties
Predefined Constants
The EventBase classIntroductionEventBase 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. Warning
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! Class synopsis
EventBase
final
class EventBase
{
/* Constants */
const
integer
EventBase::LOOP_ONCE
= 1
;
const
integer
EventBase::LOOP_NONBLOCK
= 2
;
const
integer
EventBase::NOLOCK
= 1
;
const
integer
EventBase::STARTUP_IOCP
= 4
;
const
integer
EventBase::NO_CACHE_TIME
= 8
;
const
integer
EventBase::EPOLL_USE_CHANGELIST
= 16
;
/* Methods */
public
__construct
([
EventConfig
$cfg
] )
public
void
dispatch
( void
)
public
bool
exit
([
double
$timeout
] )
public
int
getFeatures
( void
)
public
string
getMethod
([
EventConfig
$cfg
] )
public
double
getTimeOfDayCached
( void
)
public
bool
gotExit
( void
)
public
bool
gotStop
( void
)
public
bool
loop
([
int
$flags
] )
public
bool
priorityInit
(
int
$n_priorities
)
public
bool
reInit
( void
)
public
bool
stop
( void
)
}Predefined Constants
The EventBuffer classIntroductionEventBuffer 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
EventBuffer
class EventBuffer
{
/* Constants */
const
integer
EventBuffer::EOL_ANY
= 0
;
const
integer
EventBuffer::EOL_CRLF
= 1
;
const
integer
EventBuffer::EOL_CRLF_STRICT
= 2
;
const
integer
EventBuffer::EOL_LF
= 3
;
const
integer
EventBuffer::PTR_SET
= 0
;
const
integer
EventBuffer::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
void
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
void
pullup
(
string
$size
)
public
string
read
(
int
$max_bytes
)
public
string
read
(
mixed
$fd
,
int
$howmuch
)
public
void
readLine
(
string
$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
void
write
(
mixed
}$fd
[,
int
$howmuch
] )Properties
Predefined Constants
The EventBufferEvent classIntroductionRepresents 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:
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. Class synopsis
EventBufferEvent
final
class EventBufferEvent
{
/* Constants */
const
integer
EventBufferEvent::READING
= 1
;
const
integer
EventBufferEvent::WRITING
= 2
;
const
integer
EventBufferEvent::EOF
= 16
;
const
integer
EventBufferEvent::ERROR
= 32
;
const
integer
EventBufferEvent::TIMEOUT
= 64
;
const
integer
EventBufferEvent::CONNECTED
= 128
;
const
integer
EventBufferEvent::OPT_CLOSE_ON_FREE
= 1
;
const
integer
EventBufferEvent::OPT_THREADSAFE
= 2
;
const
integer
EventBufferEvent::OPT_DEFER_CALLBACKS
= 4
;
const
integer
EventBufferEvent::OPT_UNLOCK_CALLBACKS
= 8
;
const
integer
EventBufferEvent::SSL_OPEN
= 0
;
const
integer
EventBufferEvent::SSL_CONNECTING
= 1
;
const
integer
EventBufferEvent::SSL_ACCEPTING
= 2
;
/* Properties */
public
integer
$fd
;
public
integer
$priority
;
public
readonly
EventBuffer
$input
;
public
readonly
EventBuffer
$output
;
/* Methods */
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
]]]]] )
public
static
array
createPair
(
EventBase
$base
[,
int
$options
= 0
] )
public
bool
disable
(
int
$events
)
public
bool
enable
(
string
$events
)
public
void
free
( void
)
public
string
getDnsErrorString
( void
)
public
int
getEnabled
( void
)
public
EventBuffer
getInput
( void
)
public
EventBuffer
getOutput
( void
)
public
int
read
(
string
&$data
,
int
$size
)
public
bool
readBuffer
(
EventBuffer
$buf
)
public
void
setCallbacks
(
callable
$readcb
,
callable
$writecb
,
callable
$eventcb
[,
string
$arg
] )
public
bool
setPriority
(
int
$priority
)
public
bool
setTimeouts
(
int
$timeout_read
,
int
$timeout_write
)
public
void
setWatermark
(
int
$events
,
int
$lowmark
,
int
$highmark
)
public
void
sslError
( void
)
public
static
EventBufferEvent
sslFilter
(
EventBase
$base
,
EventBufferEvent
$underlying
,
EventSslContext
$ctx
,
int
$state
[,
int
$options
= 0
] )
public
void
sslRenegotiate
( void
)
public
static
EventBufferEvent
sslSocket
(
EventBase
$base
,
mixed
$socket
,
EventSslContext
$ctx
,
int
$state
[,
int
$options
] )
public
bool
write
(
string
$data
)
public
bool
writeBuffer
(
EventBuffer
}$buf
)Properties
Predefined Constants
The EventConfig classIntroductionRepresents configuration structure which could be used in construction of the EventBase . Class synopsis
EventConfig
final
class EventConfig
{
/* Constants */
const
integer
EventConfig::FEATURE_ET
= 1
;
const
integer
EventConfig::FEATURE_O1
= 2
;
const
integer
EventConfig::FEATURE_FDS
= 4
;
/* Methods */
public
bool
avoidMethod
(
int
$method
)
public
__construct
( void
)
public
bool
requireFeatures
(
int
$feature
)
public
void
setMaxDispatchInterval
(
int
}$max_interval
,
int
$max_callbacks
,
int
$min_priority
)Predefined Constants
The EventDnsBase classIntroductionRepresents Libevent's DNS base structure. Used to resolve DNS asyncronously, parse configuration files like resolv.conf etc. Class synopsis
EventDnsBase
final
class EventDnsBase
{
/* Constants */
const
integer
EventDnsBase::OPTION_SEARCH
= 1
;
const
integer
EventDnsBase::OPTION_NAMESERVERS
= 2
;
const
integer
EventDnsBase::OPTION_MISC
= 4
;
const
integer
EventDnsBase::OPTION_HOSTSFILE
= 8
;
const
integer
EventDnsBase::OPTIONS_ALL
= 15
;
/* Methods */
public
bool
addNameserverIp
(
string
$ip
)
public
void
addSearch
(
string
$domain
)
public
void
clearSearch
( void
)
public
__construct
(
EventBase
$base
,
bool
$initialize
)
public
void
countNameservers
( void
)
public
bool
loadHosts
(
string
$hosts
)
public
bool
parseResolvConf
(
int
$flags
,
string
$filename
)
public
bool
setOption
(
string
$option
,
string
$value
)
public
bool
setSearchNdots
(
int
}$ndots
)Predefined Constants
The EventHttp classIntroductionRepresents HTTP server. Class synopsis
EventHttp
final
class EventHttp
{
/* Methods */
public
bool
accept
(
mixed
$socket
)
public
bool
addServerAlias
(
string
$alias
)
public
void
bind
(
string
$address
,
int
$port
)
public
__construct
(
EventBase
$base
)
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 classIntroductionRepresents an HTTP connection. Class synopsis
EventHttpConnection
class EventHttpConnection
{
/* Methods */
public
__construct
(
EventBase
$base
,
EventDnsBase
$dns_base
,
string
$address
,
int
$port
)
public
EventBase
getBase
( void
)
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 classIntroductionRepresents an HTTP request. Class synopsis
EventHttpRequest
class EventHttpRequest
{
/* Constants */
const
integer
EventHttpRequest::CMD_GET
= 1
;
const
integer
EventHttpRequest::CMD_POST
= 2
;
const
integer
EventHttpRequest::CMD_HEAD
= 4
;
const
integer
EventHttpRequest::CMD_PUT
= 8
;
const
integer
EventHttpRequest::CMD_DELETE
= 16
;
const
integer
EventHttpRequest::CMD_OPTIONS
= 32
;
const
integer
EventHttpRequest::CMD_TRACE
= 64
;
const
integer
EventHttpRequest::CMD_CONNECT
= 128
;
const
integer
EventHttpRequest::CMD_PATCH
= 256
;
const
integer
EventHttpRequest::INPUT_HEADER
= 1
;
const
integer
EventHttpRequest::OUTPUT_HEADER
= 2
;
/* Methods */
public
bool
addHeader
(
string
$key
,
string
$value
,
int
$type
)
public
void
cancel
( void
)
public
void
clearHeaders
( void
)
public
void
closeConnection
( void
)
public
__construct
(
callable
$callback
[,
mixed
$data
= NULL
] )
public
void
findHeader
(
string
$key
,
string
$type
)
public
void
free
( void
)
public
EventBufferEvent
closeConnection
( void
)
public
void
getCommand
( void
)
public
EventHttpConnection
closeConnection
( void
)
public
string
getHost
( void
)
public
EventBuffer
getInputBuffer
( void
)
public
array
getInputHeaders
( void
)
public
EventBuffer
getOutputBuffer
( void
)
public
void
getOutputHeaders
( void
)
public
int
getResponseCode
( void
)
public
string
getUri
( void
)
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
( void
)
public
void
sendReplyStart
(
int
}$code
,
string
$reason
)Predefined Constants
The EventListener classIntroductionRepresents a connection listener. Class synopsis
EventListener
final
class EventListener
{
/* Constants */
const
integer
EventListener::OPT_LEAVE_SOCKETS_BLOCKING
= 1
;
const
integer
EventListener::OPT_CLOSE_ON_FREE
= 2
;
const
integer
EventListener::OPT_CLOSE_ON_EXEC
= 4
;
const
integer
EventListener::OPT_REUSEABLE
= 8
;
const
integer
EventListener::OPT_THREADSAFE
= 16
;
/* Properties */
public
readonly
int
$fd
;
/* Methods */
public
__construct
(
EventBase
$base
,
callable
$cb
,
mixed
$data
,
int
$flags
,
int
$backlog
,
mixed
$target
)
public
bool
disable
( void
)
public
bool
enable
( void
)
public
void
getBase
( void
)
public
static
bool
getSocketName
(
string
&$address
[,
mixed
&$port
] )
public
void
setCallback
(
callable
$cb
[,
mixed
$arg
= NULL
] )
public
void
setErrorCallback
(
string
}$cb
)Properties
Predefined Constants
The EventSslContext classIntroductionRepresents SSL_CTX structure. Provides methods and properties to configure the SSL context. Class synopsis
EventSslContext
final
class EventSslContext
{
/* Constants */
const
integer
EventSslContext::SSLv2_CLIENT_METHOD
= 1
;
const
integer
EventSslContext::SSLv3_CLIENT_METHOD
= 2
;
const
integer
EventSslContext::SSLv23_CLIENT_METHOD
= 3
;
const
integer
EventSslContext::TLS_CLIENT_METHOD
= 4
;
const
integer
EventSslContext::SSLv2_SERVER_METHOD
= 5
;
const
integer
EventSslContext::SSLv3_SERVER_METHOD
= 6
;
const
integer
EventSslContext::SSLv23_SERVER_METHOD
= 7
;
const
integer
EventSslContext::TLS_SERVER_METHOD
= 8
;
const
integer
EventSslContext::OPT_LOCAL_CERT
= 1
;
const
integer
EventSslContext::OPT_LOCAL_PK
= 2
;
const
integer
EventSslContext::OPT_PASSPHRASE
= 3
;
const
integer
EventSslContext::OPT_CA_FILE
= 4
;
const
integer
EventSslContext::OPT_CA_PATH
= 5
;
const
integer
EventSslContext::OPT_ALLOW_SELF_SIGNED
= 6
;
const
integer
EventSslContext::OPT_VERIFY_PEER
= 7
;
const
integer
EventSslContext::OPT_VERIFY_DEPTH
= 8
;
const
integer
EventSslContext::OPT_CIPHERS
= 9
;
/* Properties */
public
string
$local_cert
;
public
string
$local_pk
;
/* Methods */
public
__construct
(
string
}$method
,
string
$options
)Properties
Predefined Constants
The EventUtil classIntroductionEventUtil is a singleton with supplimentary methods and constants. Class synopsis
EventUtil
final
class EventUtil
{
/* Constants */
const
integer
EventUtil::AF_INET
= 2
;
const
integer
EventUtil::AF_INET6
= 10
;
const
integer
EventUtil::AF_UNSPEC
= 0
;
const
integer
EventUtil::LIBEVENT_VERSION_NUMBER
= 33559808
;
const
integer
EventUtil::SO_DEBUG
= 1
;
const
integer
EventUtil::SO_REUSEADDR
= 2
;
const
integer
EventUtil::SO_KEEPALIVE
= 9
;
const
integer
EventUtil::SO_DONTROUTE
= 5
;
const
integer
EventUtil::SO_LINGER
= 13
;
const
integer
EventUtil::SO_BROADCAST
= 6
;
const
integer
EventUtil::SO_OOBINLINE
= 10
;
const
integer
EventUtil::SO_SNDBUF
= 7
;
const
integer
EventUtil::SO_RCVBUF
= 8
;
const
integer
EventUtil::SO_SNDLOWAT
= 19
;
const
integer
EventUtil::SO_RCVLOWAT
= 18
;
const
integer
EventUtil::SO_SNDTIMEO
= 21
;
const
integer
EventUtil::SO_RCVTIMEO
= 20
;
const
integer
EventUtil::SO_TYPE
= 3
;
const
integer
EventUtil::SO_ERROR
= 4
;
const
integer
EventUtil::SOL_SOCKET
= 1
;
const
integer
EventUtil::SOL_TCP
= 6
;
const
integer
EventUtil::SOL_UDP
= 17
;
const
integer
EventUtil::IPPROTO_IP
= 0
;
const
integer
EventUtil::IPPROTO_IPV6
= 41
;
/* Methods */
abstract
public
__construct
( void
)
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
( void
)
}Predefined Constants
|