Skip to content

Stdlib: stream_socket_pair() — Unix/Windows socket pairs for IPC (ext/standard/streamsfuncs.c parity) #4996

Description

@PurHur

Category

stdlib | runtime

Problem

stream_socket_pair(int $domain, int $type, int $protocol, array &$fd): bool creates a connected pair of stream resources (typically AF_UNIX/SOCK_STREAM). Used for IPC, FastCGI-style pipes, and tests.

Not registered — function_exists('stream_socket_pair') is false on bin/vm.php.

php-src reference

Repro (today)

<?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]);
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "var_dump(function_exists(\"stream_socket_pair\"));"
php bin/vm.php repro.php
'
Engine Expected
Zend (Linux) bool(true), count 2, both resources; reads ping
This compiler undefined function

Scope (this repo)

Module Path
VM ext/standard/stream_socket_pair.php — socketpair(2) via AOT runtime or libc
Constants ensure STREAM_PF_UNIX, STREAM_SOCK_STREAM, … registered (may share #3399)
Registration ext/standard/Module.php
Tests test/compliance/cases/stdlib/stream_socket_pair.phpt
Matrix script/capability-matrix.php

Done when

  • Repro creates two stream resources and bidirectional fwrite/fread works
  • Returns false when socketpair unavailable (document platform skip in test)
  • ./script/ci-fast.sh --filter stream_socket_pair green
  • No host \stream_socket_pair() in AOT bootstrap path

Links

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions