Commit 8a7e5daa authored by Georg Brandl's avatar Georg Brandl

Fix code indentation.

parent d8f37ad1
...@@ -768,11 +768,11 @@ To test for the presence of SSL support in a Python installation, user code ...@@ -768,11 +768,11 @@ To test for the presence of SSL support in a Python installation, user code
should use the following idiom:: should use the following idiom::
try: try:
import ssl import ssl
except ImportError: except ImportError:
pass pass
else: else:
[ do something that requires SSL support ] ... # do something that requires SSL support
Client-side operation Client-side operation
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
...@@ -883,26 +883,26 @@ new socket from the other end, and use the context's :meth:`SSLContext.wrap_sock ...@@ -883,26 +883,26 @@ new socket from the other end, and use the context's :meth:`SSLContext.wrap_sock
method to create a server-side SSL socket for the connection:: method to create a server-side SSL socket for the connection::
while True: while True:
newsocket, fromaddr = bindsocket.accept() newsocket, fromaddr = bindsocket.accept()
connstream = context.wrap_socket(newsocket, server_side=True) connstream = context.wrap_socket(newsocket, server_side=True)
try: try:
deal_with_client(connstream) deal_with_client(connstream)
finally: finally:
connstream.close() connstream.close()
Then you'll read data from the ``connstream`` and do something with it till you Then you'll read data from the ``connstream`` and do something with it till you
are finished with the client (or the client is finished with you):: are finished with the client (or the client is finished with you)::
def deal_with_client(connstream): def deal_with_client(connstream):
data = connstream.recv(1024) data = connstream.recv(1024)
# empty data means the client is finished with us # empty data means the client is finished with us
while data: while data:
if not do_something(connstream, data): if not do_something(connstream, data):
# we'll assume do_something returns False # we'll assume do_something returns False
# when we're finished with client # when we're finished with client
break break
data = connstream.recv(1024) data = connstream.recv(1024)
# finished with client # finished with client
And go back to listening for new client connections (of course, a real server And go back to listening for new client connections (of course, a real server
would probably handle each client connection in a separate thread, or put would probably handle each client connection in a separate thread, or put
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment