socket_create
Create a socket (endpoint for communication).
socket_create Function synopsis
socket_create(
int $domain,
int $type,
int $protocol
): Socket|false
Parameters
$domain
Typeint
The $domain parameter specifies the protocol
family to be used by the socket.
$type
Typeint
The $type parameter selects the type of communication
to be used by the socket.
$protocol
Typeint
The $protocol parameter sets the specific
protocol within the specified $domain to be used
when communicating on the returned socket. The proper value can be
retrieved by name by using getprotobyname. If
the desired protocol is TCP, or UDP the corresponding constants
SOL_TCP, and SOL_UDP
can also be used.
Return value
TypeSocket|false
socket_create returns a Socket instance on success,
or false on error. The actual error code can be retrieved by calling
socket_last_error. This error code may be passed to
socket_strerror to get a textual explanation of the
error.
Changes to the socket_create Function
PHP 8.0
- Return type added:
Socket|false - Parameter type added for parameter #1 (
$domain):int - Parameter type added for parameter #2 (
$type):int - Parameter type added for parameter #3 (
$protocol):int
socket_create(
- $domain,
+ int $domain,
- $type,
+ int $type,
- $protocol
+ int $protocol
- )
+ ): Socket|false socket_create Function Availability
socket_create 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 |