Skip to content

socket_accept(): fix the non-blocking and socket_last_error() notes - #5986

Merged
lacatoire merged 2 commits into
php:masterfrom
qodelicious:socket-accept-fixes
Oct 21, 2026
Merged

lacatoire merged 2 commits into
php:masterfrom
qodelicious:socket-accept-fixes

Conversation

@qodelicious

Copy link
Copy Markdown
Contributor

A few fixes for the socket_accept() page.

  • socket_set_blocking() is an alias of stream_set_blocking() and doesn't take a Socket, so only socket_set_nonblock() is mentioned now. It also says false is returned without a warning when nothing is pending, since EAGAIN doesn't raise one.
  • The error from a failed accept is stored on the new socket that gets thrown away and in the global last error, not on the listening socket. So socket_last_error($sock) gives 0 and you need socket_last_error() with no argument. Updated the return value text and the server example in the sockets examples page.

Fixes #5974

@lacatoire lacatoire left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits from CI & LGTM

@qodelicious

Copy link
Copy Markdown
Contributor Author

Fixed the lint nits, both paragraphs are simpara now and CI is green. Thanks.

@lacatoire
lacatoire merged commit 73214e3 into php:master Oct 21, 2026
3 checks passed
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.

socket_accept: wrong statements about socket_set_blocking, false and socket_last_error

2 participants