Swoole\Event::isset
Check if a socket is being monitored in the event loop
説明
public static bool Swoole\Event::isset(mixed $fd, int $events
=
SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE
)
Checks whether the specified file descriptor is being monitored for the given event types in the event loop.
パラメータ
-
fd
-
File descriptor (stream/socket resource, integer, or object).
-
events
-
Event types to check (bitmask of
SWOOLE_EVENT_READ and/or SWOOLE_EVENT_WRITE).
戻り値
成功した場合に true を、失敗した場合に false を返します。
例
例1 Checking event monitoring status
<?php
$fp = stream_socket_client("tcp://www.qq.com:80");
Swoole\Event::add($fp, function ($fp) {
echo fread($fp, 8192);
}, null, SWOOLE_EVENT_READ);
var_dump(Swoole\Event::isset($fp, SWOOLE_EVENT_READ)); // Output: true
var_dump(Swoole\Event::isset($fp, SWOOLE_EVENT_WRITE)); // Output: false