The underlying sockpair() function does only support AF_UNIX at least on BSD and Linux.
socket_create_pair
(PHP 4 >= 4.1.0, PHP 5)
socket_create_pair — Cria um par de sockets irreconhecíveis e armazena-os no fds.
Descrição
bool socket_create_pair
( int $domain
, int $type
, int $protocol
, array $&fd
)
Aviso
Esta função é EXPERIMENTAL. O comportamento desta função, seu nome, incluindo toda documentação pode ser modificado sem aviso em futuras versões do PHP. Esta função deve ser usada por sua própria conta e risco.
Aviso
Esta função não está documentada; somente a lista de argumentos está disponível.
socket_create_pair
cweiske at php dot net
09-May-2009 06:45
09-May-2009 06:45
thegreatall at gmail dot com
13-Jul-2007 04:24
13-Jul-2007 04:24
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]);
?>
