Closed
Description
Documentation
The TCPServer examples here suggest that the BaseRequestHandler.handle
method should call self.request.recv
just once, and return, which closes the socket immediately, forcing the client to create a new socket and reconnect for every single request.
I think there should be at least one example where the handle
method keeps running until the client hangs, which can be indicated when recv
's returned value has a length of 0, which by the way, should be covered in the socket.recv documentation. The meaning of 0 as a returned value of socket.recv
is covered in the C API docs.
Sample code that allows multiple requests using the same connection can be seen here.
Linked PRs
- gh-112020: socketserver: Add an example for keeping the connection open #112054
- gh-112020: Update socket.rst doc - 0-bytes returned by socket.recv #112055
- [3.12] gh-112020: Document the meaning of empty bytes returned by socket.recv() (GH-112055) #115722
- [3.11] gh-112020: Document the meaning of empty bytes returned by socket.recv() (GH-112055) #115723
- gh-112020: Rework socketserver examples to be correct #129741
- [3.13] gh-112020: Rework socketserver examples to be correct (GH-129741) #129743
- [3.12] gh-112020: Rework socketserver examples to be correct (GH-129741) #129744