In PHP, socket_get_status() returns metadata about an open stream, such as whether it is blocked, timed out, seekable, or at end-of-file.
It is an alias of stream_get_meta_data(). Both names call the same function. You can use it on sockets from fsockopen() or on ordinary streams such as fopen('php://temp'). The result is an associative array of status fields.
Syntax
Call socket_get_status() with the values you need. Start with this line.
PHP
$meta = socket_get_status($stream);
Call
What it does
socket_get_status($stream)
Returns the metadata array for the stream.
stream_get_meta_data($stream)
Same call under the canonical stream name.
socket_get_status($stream)['timed_out']
Reads whether the last read timed out.
Teach both names: socket_get_status() and stream_get_meta_data(). Pass any open stream resource. Common keys include timed_out, blocked, eof, wrapper_type, stream_type, mode, unread_bytes, seekable, and uri.
Library declarations
PHP
socket_get_status(resource $stream): array
Parameters
Parameter
Description
stream
Required. An open stream resource, for example from fopen(), fsockopen(), or pfsockopen().
Return Value
Return Value
Description
array
Associative metadata about the stream's current status.
PHP Examples
Example 1 — Inspect a Temporary Stream
Open php://temp, write a little text, and print selected metadata keys with either alias name.