Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8a7e5daa
Commit
8a7e5daa
authored
Jan 02, 2011
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix code indentation.
parent
d8f37ad1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
18 deletions
+18
-18
Doc/library/ssl.rst
Doc/library/ssl.rst
+18
-18
No files found.
Doc/library/ssl.rst
View file @
8a7e5daa
...
...
@@ -768,11 +768,11 @@ To test for the presence of SSL support in a Python installation, user code
should use the following idiom::
try:
import ssl
import ssl
except ImportError:
pass
pass
else:
[ do something that requires SSL support ]
... # do something that requires SSL support
Client-side operation
^^^^^^^^^^^^^^^^^^^^^
...
...
@@ -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::
while True:
newsocket, fromaddr = bindsocket.accept()
connstream = context.wrap_socket(newsocket, server_side=True)
try:
deal_with_client(connstream)
finally:
connstream.close()
newsocket, fromaddr = bindsocket.accept()
connstream = context.wrap_socket(newsocket, server_side=True)
try:
deal_with_client(connstream)
finally:
connstream.close()
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)::
def deal_with_client(connstream):
data = connstream.recv(1024)
# empty data means the client is finished with us
while data:
if not do_something(connstream, data):
# we'll assume do_something returns False
# when we're finished with client
break
data = connstream.recv(1024)
# finished with client
data = connstream.recv(1024)
# empty data means the client is finished with us
while data:
if not do_something(connstream, data):
# we'll assume do_something returns False
# when we're finished with client
break
data = connstream.recv(1024)
# finished with client
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment