Skip to content

Commit 0cf09b4

Browse files
Gh-Novelbkap123
andcommitted
Address review: better emphasize send() vs recv() behavior
Remove informal 'I repeat:' phrasing. Restructure paragraph to clearly contrast recv() returning 0 bytes (a deliberate signal of disconnection) with send() raising OSError (an error condition — should never be called on a broken socket). Co-authored-by: bkap123 <bkap123@users.noreply.github.com>
1 parent 18fa493 commit 0cf09b4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Doc/howto/sockets.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ request, then reads a reply. That's it. The socket is discarded. This means tha
167167
a client can detect the end of the reply by receiving 0 bytes.
168168

169169
But if you plan to reuse your socket for further transfers, you need to realize
170-
that *there is no* :abbr:`EOT (End of Transfer)` *on a socket.* I repeat: if a
171-
``recv`` returns 0 bytes, the connection has been broken. A ``send`` on a
172-
broken connection will raise an :exc:`OSError` instead. If the connection has
173-
*not* been broken, you may wait on a ``recv``
170+
that *there is no* :abbr:`EOT (End of Transfer)` *on a socket.* If a ``recv``
171+
returns 0 bytes, the connection has been broken. In contrast, you should never
172+
call ``send`` on a broken socket, as it will raise an :exc:`OSError` rather than
173+
returning 0. If the connection has *not* been broken, you may wait on a
174+
``recv``
174175
forever, because the socket will *not* tell you that there's nothing more to
175176
read (for now). Now if you think about that a bit, you'll come to realize a
176177
fundamental truth of sockets: *messages must either be fixed length* (yuck), *or

0 commit comments

Comments
 (0)