Skip to content

Commit 3bbae72

Browse files
authored
Avoid potential confusion in TCP server example.
socket.recv(), as documented by the Python reference documentation, returns at most `bufsize` bytes, and the underlying TCP protocol means there is no guaranteed correspondence between what is sent by the client and what is received by the server. This conflation could mislead readers into thinking that TCP is datagram-based or has similar semantics, which will likely appear to work for simple cases, but introduce difficult to reproduce bugs.
1 parent 11312ea commit 3bbae72

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Doc/library/socketserver.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ This is the server side::
494494
def handle(self):
495495
# self.request is the TCP socket connected to the client
496496
self.data = self.request.recv(1024).strip()
497-
print("{} wrote:".format(self.client_address[0]))
497+
print("Received from {}:".format(self.client_address[0]))
498498
print(self.data)
499499
# just send back the same data, but upper-cased
500500
self.request.sendall(self.data.upper())

0 commit comments

Comments
 (0)