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(EventBase $base, mixed $socket = null, int $options = 0, callable|null $readcb = null, callable|null $writecb = null, callable|null $eventcb = null)

__construct.

bool
close()

close.

bool
connect(string $addr)

connect.

bool
connectHost(EventDnsBase|null $dns_base, string $hostname, int $port, int $family = EventUtil::AF_UNSPEC)

connectHost.

createSslFilter(EventBufferEvent $underlying, EventSslContext $ctx, int $state, int $options = 0)

createSslFilter

static array
createPair(EventBase $base, int $options = 0)

createPair.

bool
disable(int $events)

disable.

bool
enable(int $events)

enable.

void
free()

free.

string
getDnsErrorString()

getDnsErrorString.

int
getEnabled()

getEnabled.

getInput()

getInput.

getOutput()

getOutput.

string|null
read(int $size)

read.

bool
readBuffer(EventBuffer $buf)

readBuffer.

void
setCallbacks(callable $readcb, callable $writecb, callable $eventcb, mixed $arg = null)

setCallbacks.

bool
setPriority(int $priority)

setPriority.

bool
setTimeouts(float $timeout_read, float $timeout_write)

setTimeouts.

void
setWatermark(int $events, int $lowmark, int $highmark)

setWatermark.

false|string
sslError()

sslError.

sslFilter(EventBase $base, EventBufferEvent $underlying, EventSslContext $ctx, int $state, int $options = 0)

sslFilter.

string|false
sslGetCipherInfo()

sslGetCipherInfo.

string|false
sslGetCipherName()

sslGetCipherName.

string|false
sslGetCipherVersion()

sslGetCipherVersion.

string
sslGetProtocol()

sslGetProtocol.

void
sslRenegotiate()

sslRenegotiate.

sslSocket(EventBase $base, mixed $socket, EventSslContext $ctx, int $state, int $options = 0)

sslSocket.

bool
write(string $data)

write.

bool
writeBuffer(EventBuffer $buf)

writeBuffer.

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.

Parameters

EventBase $base
mixed $socket

= null

int $options

= 0

callable|null $readcb

= null

callable|null $writecb

= null

callable|null $eventcb

= null

See also

https://php.net/manual/en/eventbufferevent.construct.php

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.

Parameters

string $addr

Return Value

bool

See also

https://php.net/manual/en/eventbufferevent.connect.php

bool connectHost(EventDnsBase|null $dns_base, string $hostname, int $port, int $family = EventUtil::AF_UNSPEC)

connectHost.

Connects to a hostname with optionally asyncronous DNS.

Parameters

EventDnsBase|null $dns_base
string $hostname
int $port
int $family

= EventUtil::AF_UNSPEC

Return Value

bool

See also

https://php.net/manual/en/eventbufferevent.connecthost.php

EventBufferEvent createSslFilter(EventBufferEvent $underlying, EventSslContext $ctx, int $state, int $options = 0)

static array createPair(EventBase $base, int $options = 0)

createPair.

Creates two buffer events connected to each other.

Parameters

EventBase $base
int $options

= 0

Return Value

array

See also

https://php.net/manual/en/eventbufferevent.createpair.php

bool disable(int $events)

disable.

Disable events read, write, or both on a buffer event.

Parameters

int $events

Return Value

bool

See also

https://php.net/manual/en/eventbufferevent.disable.php

bool enable(int $events)

enable.

Enable events read, write, or both on a buffer event.

Parameters

int $events

Return Value

bool

See also

https://php.net/manual/en/eventbufferevent.enable.php

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.

Parameters

int $size

Return Value

string|null

See also

https://php.net/manual/en/eventbufferevent.read.php

bool readBuffer(EventBuffer $buf)

readBuffer.

Drains the entire contents of the input buffer and places them into buf.

Parameters

EventBuffer $buf

Return Value

bool

See also

https://php.net/manual/en/eventbufferevent.readbuffer.php

void setCallbacks(callable $readcb, callable $writecb, callable $eventcb, mixed $arg = null)

setCallbacks.

Assigns read, write and event(status) callbacks.

Parameters

callable $readcb
callable $writecb
callable $eventcb
mixed $arg (optional)

Return Value

void

See also

https://php.net/manual/en/eventbufferevent.setcallbacks.php

bool setPriority(int $priority)

setPriority.

Assign a priority to a bufferevent.

Parameters

int $priority

Return Value

bool

See also

https://php.net/manual/en/eventbufferevent.setpriority.php

bool setTimeouts(float $timeout_read, float $timeout_write)

setTimeouts.

Set the read and write timeout for a buffer event.

Parameters

float $timeout_read
float $timeout_write

Return Value

bool

See also

https://php.net/manual/en/eventbufferevent.settimeouts.php

void setWatermark(int $events, int $lowmark, int $highmark)

setWatermark.

Adjusts read and/or write watermarks.

Parameters

int $events
int $lowmark
int $highmark

Return Value

void

See also

https://php.net/manual/en/eventbufferevent.setwatermark.php

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.

Parameters

EventBase $base
EventBufferEvent $underlying
EventSslContext $ctx
int $state
int $options

= 0

Return Value

EventBufferEvent

See also

https://secure.php.net/manual/en/eventbufferevent.sslfilter.php

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.

Parameters

EventBase $base
mixed $socket
EventSslContext $ctx
int $state
int $options (optional)

Return Value

EventBufferEvent

See also

https://secure.php.net/manual/en/eventbufferevent.sslsocket.php

bool write(string $data)

write.

Adds data to a buffer event's output buffer.

Parameters

string $data

Return Value

bool

See also

https://secure.php.net/manual/en/eventbufferevent.write.php

bool writeBuffer(EventBuffer $buf)

writeBuffer.

Adds contents of the entire buffer to a buffer event's output buffer.