Category
stdlib | runtime
Problem
Zend exposes both fsockopen($hostname, $port, …) and stream_socket_client('tcp://…'). This compiler registers stream_socket_client() (via VmStreamSocketNative) and pfsockopen(), but fsockopen() itself is not registered — function_exists('fsockopen') is false.
Legacy apps, PHPMailer, and health checks call fsockopen directly; parity requires the procedural wrapper.
php-src reference
Repro (failure today)
<?php
$errno = 0; $errstr = '';
$fp = @fsockopen('127.0.0.1', 9, $errno, $errstr, 1);
var_export([function_exists('fsockopen'), is_resource($fp), $errno, $errstr]);
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "var_dump(function_exists(\"fsockopen\"), function_exists(\"stream_socket_client\"));"
php bin/vm.php repro_fsockopen.php
'
Verified 2026-06-16 harness: stream_socket_client → yes, fsockopen → no.
| Runtime |
function_exists('fsockopen') |
Connect port 9 |
| Zend PHP 8.x |
true |
false + errno |
bin/vm.php |
false |
fatal undefined function |
Scope (this repo)
| Path |
Work |
ext/standard/fsockopen.php |
New builtin — build tcp://host:port and delegate to existing stream socket helper |
ext/standard/Module.php |
Register |
ext/standard/VmStreamSocketNative.php |
Shared transport (#8954 pure path) |
| Tests |
test/compliance/cases/stdlib/fsockopen_discard_port.phpt |
Implement in ext/standard PHP; no new runtime/*.c socket table.
Done when
Related
Category
stdlib|runtimeProblem
Zend exposes both
fsockopen($hostname, $port, …)andstream_socket_client('tcp://…'). This compiler registersstream_socket_client()(viaVmStreamSocketNative) andpfsockopen(), butfsockopen()itself is not registered —function_exists('fsockopen')is false.Legacy apps, PHPMailer, and health checks call
fsockopendirectly; parity requires the procedural wrapper.php-src reference
ext/standard/fsock.c—PHP_FUNCTION(fsockopen)ext/standard/streamsfuncs.c— shared transport behindphp_stream_xport_createRepro (failure today)
Verified 2026-06-16 harness:
stream_socket_client→ yes,fsockopen→ no.function_exists('fsockopen')truefalse+ errnobin/vm.phpfalseScope (this repo)
ext/standard/fsockopen.phptcp://host:portand delegate to existing stream socket helperext/standard/Module.phpext/standard/VmStreamSocketNative.phptest/compliance/cases/stdlib/fsockopen_discard_port.phptImplement in
ext/standardPHP; no newruntime/*.csocket table.Done when
function_exists('fsockopen')→trueon VMfalseresource + populated$errno/$errstron unreachable port$timeoutfloat honored (subset matching Zend)./script/ci-fast.sh --filter fsockopengreenRelated
pfsockopenpersistent sockets