Swoole\Event->isset

Declaration

<?php
Swoole\Event->isset(int $fd, int $events = SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE)

Parameters

fd

fd of the socket

events

SWOOLE_EVENT_READ SWOOLE_EVENT_WRITE SWOOLE_EVENT_WRITE|SWOOLE_EVENT_READ

Return

success

if success, it returns TRUE, otherwise it returns FALSE.

Description

Check if the fd is registed on event on the Event Loop.

Example

<?php
use Swoole\Event;

$fp = stream_socket_client("tcp://www.google.com:80", $errno, $errstr, 30);
fwrite($fp,"GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n");

Event::add($fp, function($fp) {
    $resp = fread($fp, 8192);
    Swoole\Event::del($fp);
    fclose($fp);
}, null, SWOOLE_EVENT_READ);
var_dump(Event::isset($fp, SWOOLE_EVENT_READ));
var_dump(Event::isset($fp, SWOOLE_EVENT_WRITE));
var_dump(Event::isset($fp, SWOOLE_EVENT_READ | SWOOLE_EVENT_WRITE));