Skip to content

Stdlib: ext/sockets — socket_create/connect/read/write (ext/sockets parity) #3399

Description

@PurHur

Category

stdlib

Problem

Low-level BSD socket API (socket_create, socket_connect, socket_read, socket_write, socket_close, …) is missing. function_exists('socket_create') is false on VM.

Web and CLI networking stacks in php-src depend on ext/sockets (distinct from fsockopen streams in #3384).

php-src reference

Repro (failure today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "var_export(function_exists(\"socket_create\"));"'
# bool(false)

Zend with ext/sockets enabled: bool(true).

Minimal TCP client (after implementation):

<?php
$s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($s, '127.0.0.1', 9); // discard port — connection may fail; API must exist
socket_close($s);
echo "ok\n";

Scope (this repo)

Module Path
Extension ext/sockets/ (new Module.php, VM wrappers)
VM streams lib/VM.php or dedicated socket resource handle
Register root module loader + script/capability-matrix.php
Tests test/compliance/cases/stdlib/socket_create_basic.phpt (loopback or mock)
JIT/AOT phase 2 — VM-first

Done when

  • socket_create / socket_close registered; repro function_exists true
  • Subset: AF_INET + SOCK_STREAM + socket_connect + socket_write/socket_read on loopback matches Zend error semantics when peer absent
  • ./script/ci-fast.sh --filter socket green
  • Capability matrix row added

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