<?php
$fd = [];
$ok = @stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP, $fd);
var_dump($ok, count($fd), isset($fd[0], $fd[1]) && is_resource($fd[0]) && is_resource($fd[1]));
if ($ok) {
fwrite($fd[0], "ping");
echo stream_get_contents($fd[1]);
fclose($fd[0]);
fclose($fd[1]);
}
Category
stdlib|runtimeProblem
stream_socket_pair(int $domain, int $type, int $protocol, array &$fd): boolcreates a connected pair of stream resources (typicallyAF_UNIX/SOCK_STREAM). Used for IPC, FastCGI-style pipes, and tests.Not registered —
function_exists('stream_socket_pair')is false onbin/vm.php.php-src reference
ext/standard/streamsfuncs.c—PHP_FUNCTION(stream_socket_pair)main/streams/xp_socket.c—socketpair()transportext/sockets/sockets.c—socket_create_pair()(related OOP API in Stdlib: ext/sockets — socket_create/connect/read/write (ext/sockets parity) #3399)Repro (today)
bool(true), count 2, both resources; readspingScope (this repo)
ext/standard/stream_socket_pair.php—socketpair(2)via AOT runtime or libcSTREAM_PF_UNIX,STREAM_SOCK_STREAM, … registered (may share #3399)ext/standard/Module.phptest/compliance/cases/stdlib/stream_socket_pair.phptscript/capability-matrix.phpDone when
fwrite/freadworksfalsewhensocketpairunavailable (document platform skip in test)./script/ci-fast.sh --filter stream_socket_pairgreen\stream_socket_pair()in AOT bootstrap pathLinks