Skip to content

Stdlib: stream_socket_shutdown()/get_name TCP shutdown parity (#6043) - #18777

Merged
PurHur merged 2 commits into
masterfrom
agent/issue-6043-stream-socket-shutdown
Jul 14, 2026
Merged

PurHur merged 2 commits into
masterfrom
agent/issue-6043-stream-socket-shutdown

Conversation

@PurHur

@PurHur PurHur commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implement stream_socket_shutdown() on VM via shutdown(2) FFI on tracked socket fds, with host stream_socket_shutdown() fallback when FFI is unavailable.
  • Register builtin in ext/standard/Module.php; add compliance guard and spine includes.

Closes #6043

Root cause

stream_socket_get_name() was wired (#12223) but stream_socket_shutdown() was never registered — VM hit undefined function even though socket streams were created successfully.

php-src reference

  • ext/standard/streamsfuncs.c — PHP_FUNCTION(stream_socket_shutdown)

PHP implementation

  • ext/standard/stream_socket_shutdown.php — VM builtin
  • ext/standard/VmStreamSocketShutdownPure.php — shutdown via VmSockets::shutdownForFd() + host fallback
  • ext/sockets/VmSockets.php — thin shutdown(2) FFI

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/compliance/cases/stdlib/stream_socket_shutdown.phpt'
# 1
# 1
# 1
# 1

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter stream_socket_shutdown'
# OK (2 tests, 2 assertions)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "
$server = stream_socket_server(\"tcp://127.0.0.1:0\");
$name = stream_socket_get_name($server, false);
var_export(is_string($name));
echo \"\n\";
stream_socket_shutdown($server, STREAM_SHUT_RDWR);
var_export(feof($server));
echo \"\n\";
"'
# true
# true

Made with Cursor

PurHur and others added 2 commits July 14, 2026 05:33
)

Wire stream_socket_shutdown() on VM using socket fd shutdown with host
stream fallback; add compliance guard and spine includes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Regenerate capability docs after merge with master.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: stream_socket_shutdown()/get_name()/recvfrom()/sendto() — socket stream phase 2 (ext/standard/streamsfuncs.c)

1 participant