- swoole_event_isset
- 使用实例
- 使用实例
swoole_event_isset
检测传入的$fd是否已加入了事件监听。
bool swoole_event_isset(mixed $fd, int $events = SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE);
$fd:任意的socket文件描述符,参考swoole_event_add文档$events:检测的事件类型SWOOLE_EVENT_READ:是否监听了可读事件SWOOLE_EVENT_WRITE:是否监听了可写事件SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE:监听可读或可写事件
需要2.1.2/1.10.3或更高版本
使用实例
swoole_event_add($fd, $callback, null, SWOOLE_EVENT_READ);var_dump(swoole_event_isset($fd, SWOOLE_EVENT_READ)); //返回 truevar_dump(swoole_event_isset($fd, SWOOLE_EVENT_WRITE)); //返回 falsevar_dump(swoole_event_isset($fd, SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE)); //返回 true
