stream_socket_server
Create an Internet or Unix domain server socket.
stream_socket_server Function synopsis
stream_socket_server(
string $address,
&$error_code = null,
&$error_message = null,
int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN,
$context = null
)
Parameters
$address
Typestring
The type of socket created is determined by the transport specified
using standard URL formatting: transport://target.
$error_code
Passed by reference, OptionalDefault valuenull
If the optional $error_code and $error_message
arguments are present they will be set to indicate the actual system
level error that occurred in the system-level socket(),
bind(), and listen() calls. If
the value returned in $error_code is
0 and the function returned false, it is an
indication that the error occurred before the bind()
call. This is most likely due to a problem initializing the socket.
Note that the $error_code and
$error_message arguments will always be passed by reference.
$error_message
Passed by reference, OptionalDefault valuenull
See $error_code description.
$flags
OptionalTypeintDefault valueSTREAM_SERVER_BIND | STREAM_SERVER_LISTEN
A bitmask field which may be set to any combination of socket creation flags.
$flags accepts one or a bitmask of the following constant values:
$context
OptionalDefault valuenull
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_server Function
PHP 8.0
- Parameter name of parameter #1 changed:
$localaddressto$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 (
$flags):int - Parameter default value added for position #4 (
$flags):STREAM_SERVER_BIND | STREAM_SERVER_LISTEN - Parameter default value added for position #5 (
$context):null
stream_socket_server(
- $localaddress,
+ string $address,
- &$errcode,
+ &$error_code = null,
- &$errstring,
+ &$error_message = null,
- $flags,
+ int $flags = STREAM_SERVER_BIND | STREAM_SERVER_LISTEN,
- $context
+ $context = null
) stream_socket_server Function Availability
stream_socket_server 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 |