StreamPollHandle::isValid

Checks whether the stream is open and not at end-of-file

説明

public bool StreamPollHandle::isValid()

Checks whether the stream of the handle is still open and has not reached its end.

パラメータ

この関数にはパラメータはありません。

戻り値

Returns true if the stream is open and not at end-of-file, false otherwise.

例

例1 StreamPollHandle::isValid example

<?php
[$reader, $writer] = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);

$handle = new StreamPollHandle($reader);
var_dump($handle->isValid());

// The other end is closed, so the stream reaches its end.
fclose($writer);
var_dump($handle->isValid());

fclose($reader);
var_dump($handle->isValid());

上の例の出力は以下となります。

bool(true)
bool(false)
bool(false)

参考

  • Io\Poll\Watcher::isActive
  • feof