Skip to content

Commit c0bb4bc

Browse files
committed
gh-109532: drop redundant zero-length check from mysend example
1 parent c9f45c0 commit c0bb4bc

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

Doc/howto/sockets.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,9 @@ length message::
199199
def mysend(self, msg):
200200
totalsent = 0
201201
while totalsent < MSGLEN:
202+
# No need to check for 0 here: send() raises OSError
203+
# if the connection is broken.
202204
sent = self.sock.send(msg[totalsent:])
203-
if sent == 0:
204-
raise RuntimeError("socket connection broken")
205-
# Note: in practice, send() on a broken connection
206-
# raises OSError rather than returning 0.
207205
totalsent = totalsent + sent
208206

209207
def myreceive(self):

0 commit comments

Comments
 (0)