EventBufferEvent
final class EventBufferEvent (View source)
EventBufferEvent.
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: Decide that we want to write some data to a connection; put that data in a buffer. Wait for the connection to become writable Write as much of the data as we can 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.
Constants
READING |
|
WRITING |
|
EOF |
|
ERROR |
|
TIMEOUT |
|
CONNECTED |
|
OPT_CLOSE_ON_FREE |
|
OPT_THREADSAFE |
|
OPT_DEFER_CALLBACKS |
|
OPT_UNLOCK_CALLBACKS |
|
SSL_OPEN |
|
SSL_CONNECTING |
|
SSL_ACCEPTING |
|
Properties
int | $fd | ||
int | $priority | ||
EventBuffer | $input | ||
EventBuffer | $output |
Methods
__construct.
close.
connect.
connectHost.
createSslFilter
disable.
enable.
free.
getDnsErrorString.
getEnabled.
getInput.
getOutput.
read.
setCallbacks.
setPriority.
setTimeouts.
setWatermark.
sslError.
sslFilter.
sslGetCipherInfo.
sslGetCipherName.
sslGetCipherVersion.
sslGetProtocol.
sslRenegotiate.
sslSocket.
write.
Details
__construct(EventBase $base, mixed $socket = null, int $options = 0, callable|null $readcb = null, callable|null $writecb = null, callable|null $eventcb = null)
__construct.
Constructs EventBufferEvent object.
bool
close()
close.
Closes file descriptor associated with the current buffer event.
bool
connect(string $addr)
connect.
Connect buffer event's file descriptor to given address or UNIX socket.
bool
connectHost(EventDnsBase|null $dns_base, string $hostname, int $port, int $family = EventUtil::AF_UNSPEC)
connectHost.
Connects to a hostname with optionally asyncronous DNS.
EventBufferEvent
createSslFilter(EventBufferEvent $underlying, EventSslContext $ctx, int $state, int $options = 0)
createSslFilter
static array
createPair(EventBase $base, int $options = 0)
createPair.
Creates two buffer events connected to each other.
bool
disable(int $events)
disable.
Disable events read, write, or both on a buffer event.
bool
enable(int $events)
enable.
Enable events read, write, or both on a buffer event.
void
free()
free.
Free a buffer event.
string
getDnsErrorString()
getDnsErrorString.
Returns string describing the last failed DNS lookup attempt.
int
getEnabled()
getEnabled.
Returns bitmask of events currently enabled on the buffer event.
EventBuffer
getInput()
getInput.
Returns underlying input buffer associated with current buffer event.
EventBuffer
getOutput()
getOutput.
Returns underlying output buffer associated with current buffer event.
string|null
read(int $size)
read.
Read buffer's data.
bool
readBuffer(EventBuffer $buf)
readBuffer.
Drains the entire contents of the input buffer and places them into buf.
void
setCallbacks(callable $readcb, callable $writecb, callable $eventcb, mixed $arg = null)
setCallbacks.
Assigns read, write and event(status) callbacks.
bool
setPriority(int $priority)
setPriority.
Assign a priority to a bufferevent.
bool
setTimeouts(float $timeout_read, float $timeout_write)
setTimeouts.
Set the read and write timeout for a buffer event.
void
setWatermark(int $events, int $lowmark, int $highmark)
setWatermark.
Adjusts read and/or write watermarks.
false|string
sslError()
sslError.
Returns most recent OpenSSL error reported on the buffer event.
static EventBufferEvent
sslFilter(EventBase $base, EventBufferEvent $underlying, EventSslContext $ctx, int $state, int $options = 0)
sslFilter.
Create a new SSL buffer event to send its data over another buffer event.
string|false
sslGetCipherInfo()
sslGetCipherInfo.
Returns a textual description of the cipher.
string|false
sslGetCipherName()
sslGetCipherName.
Returns the current cipher name of the SSL connection.
string|false
sslGetCipherVersion()
sslGetCipherVersion.
Returns version of cipher used by current SSL connection.
string
sslGetProtocol()
sslGetProtocol.
Returns the name of the protocol used for current SSL.
void
sslRenegotiate()
sslRenegotiate.
Tells a bufferevent to begin SSL renegotiation.
static EventBufferEvent
sslSocket(EventBase $base, mixed $socket, EventSslContext $ctx, int $state, int $options = 0)
sslSocket.
Creates a new SSL buffer event to send its data over an SSL on a socket.
bool
write(string $data)
write.
Adds data to a buffer event's output buffer.
bool
writeBuffer(EventBuffer $buf)
writeBuffer.
Adds contents of the entire buffer to a buffer event's output buffer.