The underlying sockpair() function does only support AF_UNIX at least on BSD and Linux.
(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)
socket_create_pair — Cria um par de sockets irreconhecíveis e armazena-os no fds.
$domain
, int $type
, int $protocol
, array $&fd
) : boolEsta função é EXPERIMENTAL. O comportamento, seu nome e documentação podem mudar sem aviso em futuras versões do PHP. Utilize por sua própria conta e risco.
Esta função não está documentada; somente a lista de argumentos está disponível.
The underlying sockpair() function does only support AF_UNIX at least on BSD and Linux.
There is a syntax error in one of the code samples provided, it should look like this:
<?php
$sockets = array();
/* Setup socket pair */
if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $sockets) === false) {
echo "socket_create_pair failed. Reason: ".socket_strerror(socket_last_error());
}
/* Send and Recieve Data */
if (socket_write($sockets[0], "ABCdef123\n", strlen("ABCdef123\n")) === false) {
echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($sockets[0]));
}
if (($data = socket_read($sockets[1], strlen("ABCdef123\n"), PHP_BINARY_READ)) === false) {
echo "socket_read() failed. Reason: ".socket_strerror(socket_last_error($sockets[1]));
}
var_dump($data);
/* Close sockets */
socket_close($sockets[0]);
socket_close($sockets[1]);
?>