PHP 8.6.0 Beta 1 is available for testing

Swoole\Event::set

(PECL swoole >= 1.9.0)

Swoole\Event::setModify event listener callbacks and mask

Açıklama

public static function Swoole\Event::set(
    mixed $sock,
    callable $read_callback,
    callable $write_callback = ?,
    int $flags = ?
): bool

Modifies the event listener callbacks and mask for the given file descriptor.

Bilginize: When $read_callback is not null, the readable event callback function will be modified to the specified function.

Bilginize: When $write_callback is not null, the writable event callback function will be updated to the specified function.

Bilginize: Setting SWOOLE_EVENT_READ alone disables write event listening, while setting SWOOLE_EVENT_WRITE alone disables read event listening.

Uyarı

Swoole\Event::set replaces callbacks but does not free them. Specifying null for callbacks (e.g., read_callback/write_callback) preserves the existing callbacks instead of clearing them.

Uyarı

Listening for SWOOLE_EVENT_READ without a read_callback (or SWOOLE_EVENT_WRITE without a write_callback) will cause the operation to fail and return false.

Bağımsız Değişkenler

sock
File descriptor, stream resource, sockets resource, or object.
read_callback
Callback function for readable events.
write_callback
Callback function for writable events.
flags
Event type mask (e.g. SWOOLE_EVENT_READ, SWOOLE_EVENT_WRITE or SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE).

Dönen Değerler

Başarı durumunda true, başarısızlık durumunda false döner.

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top