stream_socket_client
Open Internet or Unix domain socket connection.
stream_socket_client Function synopsis
stream_socket_client(
string $address,
&$error_code = null,
&$error_message = null,
?float $timeout = null,
int $flags = STREAM_CLIENT_CONNECT,
$context = null
)
Parameters
$address
Typestring
Address to the socket to connect to.
$error_code
Passed by reference, OptionalDefault valuenull
Will be set to the system level error number if connection fails.
$error_message
Passed by reference, OptionalDefault valuenull
Will be set to the system level error message if the connection fails.
$timeout
OptionalType?floatDefault valuenull
Number of seconds until the connect() system call
should timeout. By default, default_socket_timeout is used.
$flags
OptionalTypeintDefault valueSTREAM_CLIENT_CONNECT
Bitmask field which may be set to any combination of connection flags.
Currently the select of connection flags is limited to
STREAM_CLIENT_CONNECT (default),
STREAM_CLIENT_ASYNC_CONNECT and
STREAM_CLIENT_PERSISTENT.
$flags accepts one or a bitmask of the following constant values:
$context
OptionalDefault valuenull
A valid context resource created with stream_context_create.
Note that the parameters
$error_codeand$error_messageare passed by reference, and contain additional/updated context data that may be useful.
Changes to the stream_socket_client Function
PHP 8.0
- Parameter name of parameter #1 changed:
$remoteaddressto$address - Parameter type added for parameter #1 (
$address):string - Parameter name of parameter #2 changed:
$errcodeto$error_code - Parameter default value added for position #2 (
$error_code):null - Parameter name of parameter #3 changed:
$errstringto$error_message - Parameter default value added for position #3 (
$error_message):null - Parameter type added for parameter #4 (
$timeout):?float - Parameter default value added for position #4 (
$timeout):null - Parameter type added for parameter #5 (
$flags):int - Parameter default value added for position #5 (
$flags):STREAM_CLIENT_CONNECT - Parameter default value added for position #6 (
$context):null
stream_socket_client(
- $remoteaddress,
+ string $address,
- &$errcode,
+ &$error_code = null,
- &$errstring,
+ &$error_message = null,
- $timeout,
+ ?float $timeout = null,
- $flags,
+ int $flags = STREAM_CLIENT_CONNECT,
- $context
+ $context = null
) stream_socket_client Function Availability
stream_socket_client 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 |