From 57bbc488083417152392e177b78a31e7ccbf2d60 Mon Sep 17 00:00:00 2001 From: projectsaturnstudios <10563160+projectsaturnstudios@users.noreply.github.com> Date: Thu, 22 Oct 2026 21:26:49 -0400 Subject: [PATCH] (0.10.x) - docs(posi): posix_listen and SOMAXCONN for v0.10.6 --- .../standalone-extensions/posi/api/constants.md | 2 +- .../posi/api/descriptors-and-paths.md | 3 ++- .../standalone-extensions/posi/changelog.md | 4 ++++ .../standalone-extensions/posi/overview.md | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ecosystem/standalone-extensions/posi/api/constants.md b/ecosystem/standalone-extensions/posi/api/constants.md index 9906b7a..fe2273e 100644 --- a/ecosystem/standalone-extensions/posi/api/constants.md +++ b/ecosystem/standalone-extensions/posi/api/constants.md @@ -28,7 +28,7 @@ Values differ per platform: `O_NONBLOCK` 4 macOS vs 0x800 Linux; `O_DIRECT` 0x40 | Names | Why not in stub | |---|---| -| `MSG_OOB`, `MSG_PEEK`, `MSG_WAITALL` | ext/sockets registers them | +| `MSG_OOB`, `MSG_PEEK`, `MSG_WAITALL`, `SOMAXCONN` | ext/sockets registers them | | `WNOHANG`, `WUNTRACED`, `WCONTINUED` | ext/pcntl registers them | | POSIX errno set `E2BIG` … `EXDEV` (each `#ifdef`) | ext-kqueue registers some | | `ECHO` | PHP keyword; stub cannot declare it. Read with `constant('ECHO')` | diff --git a/ecosystem/standalone-extensions/posi/api/descriptors-and-paths.md b/ecosystem/standalone-extensions/posi/api/descriptors-and-paths.md index ad9ce6f..44fed13 100644 --- a/ecosystem/standalone-extensions/posi/api/descriptors-and-paths.md +++ b/ecosystem/standalone-extensions/posi/api/descriptors-and-paths.md @@ -1,6 +1,6 @@ # Descriptors and paths -open/read/write family, readv, recv, fcntl, ioctl argument modes, ppoll, fdopen, fileno, dup, socket fdopen, chmod family, lstat, hostname. +open/read/write family, readv, recv, fcntl, ioctl argument modes, ppoll, fdopen, fileno, dup, socket fdopen, listen, chmod family, lstat, hostname. ## Functions @@ -20,6 +20,7 @@ Names are `microscrap/posix`'s. Signatures in `posi.stub.php`.[^stub] | `posix_fileno($stream)` | `php_stream_cast` (`AS_SOCKETD`, then `AS_FD`) | fd | false, errno `EBADF` | | `posix_dup($fd)` | `dup` | new fd | -1 | | `posix_socket_fdopen($fd)` | registered `tcp` transport factory, fd installed | socket stream | false: `EBADF` closed, `ENOTSOCK` not a socket, `EPROTOTYPE` not `SOCK_STREAM` | +| `posix_listen($fd, $backlog)` | `listen` | 0 | -1: `ENOTSOCK` not a socket, `EOPNOTSUPP` datagram | | `posix_chmod/fchmod/chown/fchown` | same | 0 | -1 | | `posix_umask($mask)` | `umask` | previous mask | — | | `posix_lstat($path)` | `lstat` | stat array | false | diff --git a/ecosystem/standalone-extensions/posi/changelog.md b/ecosystem/standalone-extensions/posi/changelog.md index 10df623..eae66de 100644 --- a/ecosystem/standalone-extensions/posi/changelog.md +++ b/ecosystem/standalone-extensions/posi/changelog.md @@ -2,6 +2,10 @@ What changed in this package, newest first. +### 2026-10-20 + +* **listen**: `posix_listen` added, `listen(2)` 1:1, with `SOMAXCONN` registered if absent ([descriptors](/docs/{{version}}/ecosystem/standalone-extensions/posi/api/descriptors-and-paths), [constants](/docs/{{version}}/ecosystem/standalone-extensions/posi/api/constants)). SocketTest 16 passed + 1 skipped on php84, zhp and the Pi. Shipped in tag v0.10.6; `PHP_POSI_VERSION` and the composer.json `version` read 0.10.6, matching the tag. + ### 2026-10-14 * **Socket descriptors**: `posix_fileno`, `posix_dup`, `posix_socket_fdopen` added for sharing one listening socket across ext-parallel threads ([descriptors](/docs/{{version}}/ecosystem/standalone-extensions/posi/api/descriptors-and-paths)). Suite 67 passed (66 + 1 skipped on php84, which has no ext-parallel). Shipped in tag v0.10.5; `PHP_POSI_VERSION` and the composer.json `version` read 0.10.6 at that tag. diff --git a/ecosystem/standalone-extensions/posi/overview.md b/ecosystem/standalone-extensions/posi/overview.md index 44a40b5..b9879e3 100644 --- a/ecosystem/standalone-extensions/posi/overview.md +++ b/ecosystem/standalone-extensions/posi/overview.md @@ -379,6 +379,23 @@ $connection = stream_socket_accept($listener); --- +##### `posix_listen(int $fd, int $backlog): int` + +Marks a bound socket as accepting connections. Returns `0`, or `-1` (same semantics as C `listen(2)`). A non-socket fails with `ENOTSOCK`, a datagram socket with `EOPNOTSUPP`. + +* `$fd` — a bound `SOCK_STREAM` socket descriptor (TCP or Unix). +* `$backlog` — the queue length for pending connections; `SOMAXCONN` asks for the system maximum. + +**Example** + +```php +$server = stream_socket_server('unix:///tmp/app.sock', $errno, $error, STREAM_SERVER_BIND); +posix_listen(posix_fileno($server), SOMAXCONN); +$connection = stream_socket_accept($server); +``` + +--- + #### Descriptor control ##### `fcntl(int $fd, int $cmd, mixed $arg, mixed &$value): int`