socket_create_pair

(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)

socket_create_pairCria um par de sockets irreconhecíveis e armazena-os no fds.

Descrição

socket_create_pair ( int $domain , int $type , int $protocol , array $&fd ) : bool
Aviso

Esta 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.

Aviso

Esta função não está documentada; somente a lista de argumentos está disponível.

add a note add a note

User Contributed Notes 2 notes

up
2
cweiske at php dot net
15 years ago
The underlying sockpair() function does only support AF_UNIX at least on BSD and Linux.
up
-6
thegreatall at gmail dot com
16 years ago
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]);
?>
To Top