Category
stdlib | runtime · php-src-strict · spec refresh 2026-06-18
Problem
Socket client parity is partial . VM registers fsockopen(), pfsockopen(), and stream_socket_client() (ext/standard/fsockopen.php, stream_socket_client.php, Module.php — #8954 closed). Remaining gaps:
errno / errstr strings — VM returns 'Connection failed' where Zend returns 'Connection refused' for ECONNREFUSED (errno 111).
libc FFI — VmStreamSocketNative still uses socket FFI; self-host wants pure PHP transport (php-in-php: VmStreamSocketNative — TCP/UDP connect without libc socket FFI (#1492, streamsfuncs.c) #8953 ).
UDP / timeout / persistent socket edge cases — not fully guarded vs php-src streamsfuncs.c.
Blocks: #3384 persistent sockets, #3131 proc_open socket pipes, FastCGI upstream (#173 ).
php-src reference
Repro
Phase 1 — registration (GREEN)
./script/docker-exec.sh -- bash -lc ' source script/php-env.sh
php bin/vm.php -r "var_export([function_exists(\"fsockopen\"), function_exists(\"stream_socket_client\"), function_exists(\"pfsockopen\")]);"'
# array(true, true, true)
Phase 2 — connect + errno (verified 2026-06-18)
<?php
$ errno = 0 ;
$ errstr = '' ;
$ fp = @fsockopen ('127.0.0.1 ' , 9 , $ errno , $ errstr , 1 );
var_export ([is_resource ($ fp ), $ errno , $ errstr ]);
echo "\n" ;
php repro_fsock.php
./script/docker-exec.sh -- bash -lc ' source script/php-env.sh && php bin/vm.php repro_fsock.php'
./script/docker-exec.sh -- bash -lc ' source script/php-env.sh && php bin/jit.php repro_fsock.php'
Check
Zend PHP 8.2
VM / JIT today
is_resource($fp)
false
false ✅
$errno
111
111 ✅
$errstr
'Connection refused'
'Connection failed' ❌
JIT compiles
n/a
works (no LogicException)
Phase 3 — successful TCP (when listener available)
# Optional: start listener on 127.0.0.1:9876, then:
php bin/vm.php -r ' $fp=fsockopen("127.0.0.1",9876); var_dump(is_resource($fp)); fclose($fp);'
Scope (this repo)
Module
Path
VM builtins
ext/standard/fsockopen.php, stream_socket_client.php, VmStreamSocketNative.php
Transport
Pure PHP socket path per #8953
JIT/AOT
Verify parity with VM (JIT connect path exists)
Tests
test/compliance/cases/stdlib/fsockopen_tcp.phpt — assert errno and errstr
Done when (php-src-strict)
Related
Category
stdlib|runtime· php-src-strict · spec refresh 2026-06-18Problem
Socket client parity is partial. VM registers
fsockopen(),pfsockopen(), andstream_socket_client()(ext/standard/fsockopen.php,stream_socket_client.php,Module.php— #8954 closed). Remaining gaps:'Connection failed'where Zend returns'Connection refused'for ECONNREFUSED (errno 111).VmStreamSocketNativestill uses socket FFI; self-host wants pure PHP transport (php-in-php: VmStreamSocketNative — TCP/UDP connect without libc socket FFI (#1492, streamsfuncs.c) #8953).streamsfuncs.c.Blocks: #3384 persistent sockets, #3131
proc_opensocket pipes, FastCGI upstream (#173).php-src reference
ext/standard/fsock.c—PHP_FUNCTION(fsockopen),pfsockopenmain/streams/streams.c—php_stream_xport_create, timeout/connectext/standard/streamsfuncs.c—stream_socket_clientRepro
Phase 1 — registration (GREEN)
Phase 2 — connect + errno (verified 2026-06-18)
is_resource($fp)falsefalse✅$errno111111✅$errstr'Connection refused''Connection failed'❌Phase 3 — successful TCP (when listener available)
Scope (this repo)
ext/standard/fsockopen.php,stream_socket_client.php,VmStreamSocketNative.phptest/compliance/cases/stdlib/fsockopen_tcp.phpt— assert errno and errstrDone when (php-src-strict)
$errstr === 'Connection refused'on VM and JIT (match Zend for errno 111)./script/ci-fast.sh --filter fsockopengreenRelated