Skip to content

Conversation

@Gh-Novel
Copy link

@Gh-Novel Gh-Novel commented Feb 12, 2026

Summary

Corrects an inaccuracy in the Socket Programming HOWTO (Doc/howto/sockets.rst) about send() behavior when the remote end has disconnected.

The existing text stated "if a socket send or recv returns after handling 0 bytes, the connection has been broken." In practice, send() on a broken connection raises OSError (specifically BrokenPipeError/EPIPE) rather than returning 0. Only recv() returns 0 bytes to indicate disconnection.

Changes

  • Fixed the prose to correctly distinguish between send() (raises OSError) and recv() (returns 0 bytes)
    • Added a clarifying comment to the mysend code example

Testing

  • Sphinx doc build passes with zero warnings
    • Verified with a Python test script that send() raises BrokenPipeError and recv() returns b''

📚 Documentation preview 📚: https://cpython-previews--144747.org.readthedocs.build/

…onnection

Correct the claim that send() returns 0 bytes on a broken connection.
In practice, send() on a broken connection raises OSError (EPIPE) rather
than returning 0. Only recv() returns 0 bytes to indicate disconnection.

Add a clarifying comment to the mysend example noting this distinction.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant