Skip to content

Stdlib: stream_socket_pair() — connected socket pair (ext/standard/streams.c parity) #3437

Description

@PurHur

Category

stdlib

Problem

stream_socket_pair() creates two connected stream endpoints (used for IPC, subprocess pipes, and tests). It is registered in Zend but missing from ext/standard/Module.php.

php-src reference

  • ext/standard/streams.c — PHP_FUNCTION(stream_socket_pair)
  • ext/standard/basic_functions.stub.php — (array|false) stream_socket_pair(int $domain, int $type, int $protocol)

Repro (failure today)

<?php
var_export(function_exists('stream_socket_pair'));
$s = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
var_export($s);
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
php repro.php

Zend PHP: function_exists → true; returns two stream resources
This compiler: function_exists → false

Scope (this repo)

Done when

  • Repro returns two readable/writable streams on Linux STREAM_PF_UNIX
  • Errors for unsupported domain/type match Zend ValueError/Warning subset
  • ./script/ci-fast.sh --filter stream_socket_pair green
  • docs/capabilities.md row

Links

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on May 29, 2026
  2. PurHur commented on Jun 13, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  3. PurHur commented on Jun 13, 2026

    @PurHur
    OwnerAuthor

    Merged via #8316.

    Verification

    • `php bin/vm.php test/compliance/cases/stdlib/stream_socket_pair.phpt` → `1 / pair_ok / ping`
    • `vendor/bin/phpunit --filter stream_socket_pair test/compliance/` → OK (3 tests)
    • `vendor/bin/phpunit --filter VmStreamSocketPairNativeTest` → OK (2 tests)
    • `php bin/compile.php -l test/fixtures/aot/compile-only/stream_socket_pair_smoke.php` → exit 0

    VM path uses `VmStreamSocketPairNative` (libc socketpair FFI). JIT/AOT `call()` lowering remains deferred.

  4. PurHur commented on Jun 13, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run (stream_socket_pair JIT/AOT lowering, phase 2 of #3437).

  5. PurHur commented on Jun 13, 2026

    @PurHur
    OwnerAuthor

    Merged via #8386

    PHP path: StreamSocketPairJit emits __compiler_stream_socket_pair (libc socketpair + fdopen, registers both ends in phpc_stream_handles). JitStreamSocketPair wraps the returned hashtable as a PHP array of stream handles.

    C shrink: 0 lines (no new runtime/ symbols).

    Verification (green):

    • vendor/bin/phpunit --filter stream_socket_pair test/compliance/ → OK (6 tests, VM + JIT)
    • php bin/compile.php -l test/fixtures/aot/compile-only/stream_socket_pair_smoke.php → exit 0
    • docs/capabilities.md: stream_socket_pair yes/yes/yes
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