stream_select
Runs the equivalent of the select() system call on the given arrays of streams with a timeout specified by seconds and microseconds.
stream_select Function synopsis
stream_select(
?array &$read,
?array &$write,
?array &$except,
?int $seconds,
?int $microseconds = null,
$context = null
): int|false
Parameters
$read
Passed by referenceType?array
The streams listed in the $read array will be watched to
see if characters become available for reading (more precisely, to see if
a read will not block - in particular, a stream resource is also ready on
end-of-file, in which case an fread will return
a zero length string).
$write
Passed by referenceType?array
The streams listed in the $write array will be
watched to see if a write will not block.
$except
Passed by referenceType?array
The streams listed in the $except array will be
watched for high priority exceptional ("out-of-band") data arriving.
$seconds
Type?int
The $seconds and $microseconds
together form the timeout parameter,
$seconds specifies the number of seconds while
$microseconds the number of microseconds.
The $timeout is an upper bound on the amount of time
that stream_select will wait before it returns.
If $seconds is set to 0 and
$microseconds is 0 or null,
stream_select will not wait for data - instead it will return immediately,
indicating the current status of the streams.
$microseconds
OptionalType?intDefault valuenull
See $seconds description.
$context
OptionalDefault valuenull
Note that the parameters
$read,$write, and$exceptare passed by reference, and contain additional/updated context data that may be useful.
Return value
Typeint|false
On success stream_select returns the number of
stream resources contained in the modified arrays, which may be zero if
the timeout expires before anything interesting happens. On error false
is returned and a warning raised (this can happen if the system call is
interrupted by an incoming signal).
Changes to the stream_select Function
PHP 8.6
- Optional parameter added - #6:
$context = null
stream_select(
?array &$read,
?array &$write,
?array &$except,
?int $seconds,
- ?int $microseconds = null
+ ?int $microseconds = null,
+ $context = null
): int|false PHP 8.1
- Parameter type changed for parameter #5 (
$microseconds):intto?int - Parameter default value changed for position #5 (
$microseconds):0tonull
stream_select(
?array &$read,
?array &$write,
?array &$except,
?int $seconds,
- int $microseconds = 0
+ ?int $microseconds = null
): int|false PHP 8.0
- Return type added:
int|false - Parameter name of parameter #1 changed:
$read_streamsto$read - Parameter type added for parameter #1 (
$read):?array - Parameter name of parameter #2 changed:
$write_streamsto$write - Parameter type added for parameter #2 (
$write):?array - Parameter name of parameter #3 changed:
$except_streamsto$except - Parameter type added for parameter #3 (
$except):?array - Parameter name of parameter #4 changed:
$tv_secto$seconds - Parameter type added for parameter #4 (
$seconds):?int - Parameter name of parameter #5 changed:
$tv_usecto$microseconds - Parameter type added for parameter #5 (
$microseconds):int - Parameter default value added for position #5 (
$microseconds):0
stream_select(
- &$read_streams,
+ ?array &$read,
- &$write_streams,
+ ?array &$write,
- &$except_streams,
+ ?array &$except,
- $tv_sec,
+ ?int $seconds,
- $tv_usec
+ int $microseconds = 0
- )
+ ): int|false stream_select Function Availability
stream_select Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |