socket_send
Function • Params and return types changed in PHP 8.0
Sends data to a connected socket.
socket_send Function synopsis
socket_send(
Socket $socket,
string $data,
int $length,
int $flags
): int|false
Parameters
$socket
TypeSocket
A Socket instance created with socket_create
or socket_accept.
$data
Typestring
A buffer containing the data that will be sent to the remote host.
$length
Typeint
The number of bytes that will be sent to the remote host from
$data.
$flags
Typeint
The value of $flags can be any combination of
the following flags, joined with the binary OR (|)
operator.
$flags accepts one or a bitmask of the following constant values:
Return value
Typeint|false
socket_send returns the number of bytes sent, or false on error.
Changes to the socket_send Function
PHP 8.0
- Return type added:
int|false - Parameter type added for parameter #1 (
$socket):Socket - Parameter name of parameter #2 changed:
$bufto$data - Parameter type added for parameter #2 (
$data):string - Parameter name of parameter #3 changed:
$lento$length - Parameter type added for parameter #3 (
$length):int - Parameter type added for parameter #4 (
$flags):int
socket_send(
- $socket,
+ Socket $socket,
- $buf,
+ string $data,
- $len,
+ int $length,
- $flags
+ int $flags
- )
+ ): int|false socket_send Function Availability
socket_send 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 |