8000 gh-112020: socketserver: Add an example for keeping the connection open by talcs · Pull Request #112054 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-112020: socketserver: Add an example for keeping the connection open #112054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update socketserver.rst
  • Loading branch information
talcs authored Feb 21, 2024
commit d860d46848c2a7d3d402ae5c9410d3b741fb1706
4 changes: 4 additions & 0 deletions Doc/library/socketserver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,8 @@ This is the server side::
print(self.data)
# just send back the same data, but upper-cased
self.request.sendall(self.data.upper())
# Receive next message from client. Will return an empty message
# if client has hung up
self.data = self.request.recv(1024)

if __name__ == "__main__":
Expand Down Expand Up @@ -527,6 +529,8 @@ objects that simplify communication by providing the standard file interface)::
# Likewise, self.wfile is a file-like object used to write back
# to the client
self.wfile.write(self.data.upper())
# Receive next message from client. Will return an empty message
# if client has hung up
self.data = self.rfile.readline()

The difference is that the ``readline()`` call in the second handler will call
Expand Down
0