fsockopen
Open Internet or Unix domain socket connection.
fsockopen Function synopsis
fsockopen(
string $hostname,
int $port = -1,
&$error_code = null,
&$error_message = null,
?float $timeout = null
)
Parameters
$hostname
Typestring
If OpenSSL support is
installed, you may prefix the $hostname
with either ssl:// or tls:// to
use an SSL or TLS client connection over TCP/IP to connect to the
remote host.
$port
OptionalTypeintDefault value-1
The port number. This can be omitted and skipped with
-1 for transports that do not use ports, such as
unix://.
$error_code
Passed by reference, OptionalDefault valuenull
If provided, holds the system level error number that occurred in the
system-level connect() call.
$error_message
Passed by reference, OptionalDefault valuenull
The error message as a string.
$timeout
OptionalType?floatDefault valuenull
The connection timeout, in seconds. When null, the
default_socket_timeoutphp.ini setting is used.
Note that the parameters
$error_codeand$error_messageare passed by reference, and contain additional/updated context data that may be useful.
Changes to the fsockopen Function
PHP 8.0
- Parameter type added for parameter #1 (
$hostname):string - Parameter type added for parameter #2 (
$port):int - Parameter default value added for position #2 (
$port):-1 - Parameter name of parameter #3 changed:
$errnoto$error_code - Parameter default value added for position #3 (
$error_code):null - Parameter name of parameter #4 changed:
$errstrto$error_message - Parameter default value added for position #4 (
$error_message):null - Parameter type added for parameter #5 (
$timeout):?float - Parameter default value added for position #5 (
$timeout):null
fsockopen(
- $hostname,
+ string $hostname,
- $port,
+ int $port = -1,
- &$errno,
+ &$error_code = null,
- &$errstr,
+ &$error_message = null,
- $timeout
+ ?float $timeout = null
) fsockopen Function Availability
fsockopen Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Supported | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Security-Fixes Only | 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 |