final class EventListener (View source)

EventListener.

Represents a connection listener.

Constants

OPT_LEAVE_SOCKETS_BLOCKING

OPT_CLOSE_ON_FREE

OPT_CLOSE_ON_EXEC

OPT_REUSEABLE

OPT_THREADSAFE

OPT_DISABLED

OPT_DEFERRED_ACCEPT

Properties

int $fd

Methods

__construct(EventBase $base, callable $cb, mixed $data, int $flags, int $backlog, mixed $target)

__construct.

bool
disable()

disable.

bool
enable()

enable.

void
free()

No description

void
getBase()

getBase.

static bool
getSocketName(string $address, int $port)

getSocketName.

void
setCallback(callable $cb, mixed $arg = null)

setCallback.

void
setErrorCallback(string $cb)

setErrorCallback.

Details

__construct(EventBase $base, callable $cb, mixed $data, int $flags, int $backlog, mixed $target)

__construct.

Creates new connection listener associated with an event base.

Parameters

EventBase $base

Associated event base.

callable $cb

A callable that will be invoked when new connection received.

mixed $data

Custom user data attached to cb.

int $flags

Bit mask of EventListener::OPT_* constants. See EventListener constants.

int $backlog

Controls the maximum number of pending connections that the network stack should allow to wait in a not-yet-accepted state at any time; see documentation for your system’s listen function for more details. If backlog is negative, Libevent tries to pick a good value for the backlog ; if it is zero, Event assumes that listen is already called on the socket (target).

mixed $target

May be string, socket resource, or a stream associated with a socket. In case if target is a string, the string will be parsed as network address. It will be interpreted as a UNIX domain socket path, if prefixed with 'unix:', e.g. 'unix:/tmp/my.sock'.

See also

https://secure.php.net/manual/en/eventlistener.construct.php

bool disable()

disable.

Disables an event connect listener object.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventlistener.disable.php

bool enable()

enable.

Enables an event connect listener object.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventlistener.enable.php

void free()

No description

Return Value

void

void getBase()

getBase.

Returns event base associated with the event listener.

static bool getSocketName(string $address, int $port)

getSocketName.

Retreives the current address to which the listener's socket is bound.

Parameters

string $address

Output parameter. IP-address depending on the socket address family.

int $port

Output parameter. The port the socket is bound to.

Return Value

bool

Returns true on success or false on failure.

See also

https://secure.php.net/manual/en/eventlistener.getsocketname.php

void setCallback(callable $cb, mixed $arg = null)

setCallback.

The setCallback purpose.

Parameters

callable $cb

The new callback for new connections. Ignored if null. Should match the following prototype: void callback EventListener listener null mixed fd null array address null mixed arg null listener The EventListener object. fd The file descriptor or a resource associated with the listener. address Array of two elements: IP address and the server port. arg User custom data attached to the callback.

mixed $arg

= null

Return Value

void

See also

https://secure.php.net/manual/en/eventlistener.setcallback.php

void setErrorCallback(string $cb)

setErrorCallback.

Set event listener's error callback.

Parameters

string $cb

The error callback. Should match the following prototype: void callback EventListener listener null mixed data null listener The EventListener object. data User custom data attached to the callback.

Return Value

void

See also

https://secure.php.net/manual/en/eventlistener.seterrorcallback.php