Skip to content

Misleading socketserver.TCPServer example recv semantics #111112

Closed
@aidanholm

Description

@aidanholm

Documentation

Issue (on https://docs.python.org/3/library/socketserver.html#socketserver-tcpserver-example):

        self.data = self.request.recv(1024).strip()
        print("{} wrote:".format(self.client_address[0]))

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.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions