socket_select
Runs the select() system call on the given arrays of sockets with a specified timeout.
socket_select Function synopsis
socket_select(
?array &$read,
?array &$write,
?array &$except,
?int $seconds,
int $microseconds = 0
): int|false
Parameters
$read
Passed by referenceType?array
The sockets 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 socket
is also ready on end-of-file, in which case a
socket_read will return a zero length string).
$write
Passed by referenceType?array
The sockets listed in the $write array will be
watched to see if a write will not block.
$except
Passed by referenceType?array
The sockets listed in the $except array will be
watched for exceptions.
$seconds
Type?int
$microseconds
OptionalTypeintDefault value0
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
Be sure to use the === operator when checking for an
error. Since the socket_select may return 0 the
comparison with == would evaluate to true:
Changes to the socket_select Function
PHP 8.0
- Return type added:
int|false - Parameter name of parameter #1 changed:
$read_fdsto$read - Parameter type added for parameter #1 (
$read):?array - Parameter name of parameter #2 changed:
$write_fdsto$write - Parameter type added for parameter #2 (
$write):?array - Parameter name of parameter #3 changed:
$except_fdsto$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
socket_select(
- &$read_fds,
+ ?array &$read,
- &$write_fds,
+ ?array &$write,
- &$except_fds,
+ ?array &$except,
- $tv_sec,
+ ?int $seconds,
- $tv_usec
+ int $microseconds = 0
- )
+ ): int|false socket_select Function Availability
socket_select Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.7Future Release | Yes |
| 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 |