class ZMQPoll (View source)

Class ZMQPoll

Methods

int
add(ZMQSocket $entry, int $type)

(PECL zmq >= 0.5.0) Adds a new item to the poll set and returns the internal id of the added item.

clear()

(PECL zmq >= 1.0.4) Clears all elements from the poll set.

int
count()

(PECL zmq >= 0.5.0) Count the items in the poll set.

int[]
getLastErrors()

(PECL zmq >= 0.5.0) Returns the ids of the objects that had errors in the last poll.

int
poll(array $readable, array $writable, int $timeout = -1)

(PECL zmq >= 0.5.0) Polls the items in the current poll set.

bool
remove(ZMQSocket|string|mixed $item)

(PECL zmq >= 0.5.0) Remove item from the poll set.

Details

int add(ZMQSocket $entry, int $type)

(PECL zmq >= 0.5.0) Adds a new item to the poll set and returns the internal id of the added item.

The item can be removed from the poll set using the returned string id. Returns a string id of the added item which can be later used to remove the item.

Parameters

ZMQSocket $entry

ZMQSocket object or a PHP stream resource

int $type

Defines what activity the socket is polled for. See ZMQ::POLL_IN and ZMQ::POLL_OUT constants.

Return Value

int

Returns a string id of the added item which can be later used to remove the item. Throws ZMQPollException on error.

Exceptions

ZMQPollException

ZMQPoll clear()

(PECL zmq >= 1.0.4) Clears all elements from the poll set.

Return Value

ZMQPoll

Returns the current object.

int count()

(PECL zmq >= 0.5.0) Count the items in the poll set.

Return Value

int

Returns an integer representing the amount of items in the poll set.

int[] getLastErrors()

(PECL zmq >= 0.5.0) Returns the ids of the objects that had errors in the last poll.

Returns an array containing ids for the items that had errors in the last poll. Empty array is returned if there were no errors.

Return Value

int[]

int poll(array $readable, array $writable, int $timeout = -1)

(PECL zmq >= 0.5.0) Polls the items in the current poll set.

The readable and writable items are returned in the readable and writable parameters. ZMQPoll::getLastErrors() can be used to check if there were errors. Returns an int representing amount of items with activity.

Parameters

array $readable

Array where readable ZMQSockets/PHP streams are returned. The array will be cleared at the beginning of the operation.

array $writable

Array where writable ZMQSockets/PHP streams are returned. The array will be cleared at the beginning of the operation.

int $timeout

Timeout for the operation. -1 means that poll waits until at least one item has activity. Please note that starting from version 1.0.0 the poll timeout is defined in milliseconds, rather than microseconds.

Return Value

int

Exceptions

ZMQPollException

bool remove(ZMQSocket|string|mixed $item)

(PECL zmq >= 0.5.0) Remove item from the poll set.

The item parameter can be ZMQSocket object, a stream resource or the id returned from ZMQPoll::add() method. Returns true if the item was removed and false if the object with given id does not exist in the poll set.

Parameters

ZMQSocket|string|mixed $item

The ZMQSocket object, PHP stream or string id of the item.

Return Value

bool

Returns true if the item was removed and false if the object with given id does not exist in the poll set.