diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-02 22:35:59 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-01-02 22:35:59 (GMT) |
commit | cae7c1d824fa77bb100356a7ed81f16b88e531c0 (patch) | |
tree | 726e09d5e287af5f6172b0a4d6b85dd47b6a6989 /Doc/library/ssl.rst | |
parent | 59dd7abc561204b94852bdaefe2491357da980e5 (diff) | |
download | cpython-cae7c1d824fa77bb100356a7ed81f16b88e531c0.zip cpython-cae7c1d824fa77bb100356a7ed81f16b88e531c0.tar.gz cpython-cae7c1d824fa77bb100356a7ed81f16b88e531c0.tar.bz2 |
Merged revisions 87653-87655 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r87653 | antoine.pitrou | 2011-01-02 23:06:53 +0100 (dim., 02 janv. 2011) | 3 lines
Clarify behaviour of close() and shutdown() on sockets.
........
r87654 | antoine.pitrou | 2011-01-02 23:09:27 +0100 (dim., 02 janv. 2011) | 3 lines
Add a shutdown() call in the server example.
........
r87655 | antoine.pitrou | 2011-01-02 23:12:22 +0100 (dim., 02 janv. 2011) | 3 lines
Some nits.
........
Diffstat (limited to 'Doc/library/ssl.rst')
-rw-r--r-- | Doc/library/ssl.rst | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/Doc/library/ssl.rst b/Doc/library/ssl.rst index d377072..2902318 100644 --- a/Doc/library/ssl.rst +++ b/Doc/library/ssl.rst @@ -1,8 +1,8 @@ -:mod:`ssl` --- SSL wrapper for socket objects -============================================= +:mod:`ssl` --- TLS/SSL wrapper for socket objects +================================================= .. module:: ssl - :synopsis: SSL wrapper for socket objects + :synopsis: TLS/SSL wrapper for socket objects .. moduleauthor:: Bill Janssen <bill.janssen@gmail.com> .. sectionauthor:: Bill Janssen <bill.janssen@gmail.com> @@ -537,13 +537,17 @@ the other end, and use :func:`wrap_socket` to create a server-side SSL context for it:: while True: - newsocket, fromaddr = bindsocket.accept() - connstream = ssl.wrap_socket(newsocket, - server_side=True, - certfile="mycertfile", - keyfile="mykeyfile", - ssl_version=ssl.PROTOCOL_TLSv1) - deal_with_client(connstream) + newsocket, fromaddr = bindsocket.accept() + connstream = ssl.wrap_socket(newsocket, + server_side=True, + certfile="mycertfile", + keyfile="mykeyfile", + ssl_version=ssl.PROTOCOL_TLSv1) + try: + deal_with_client(connstream) + finally: + connstream.shutdown(socket.SHUT_RDWR) + connstream.close() Then you'd read data from the ``connstream`` and do something with it till you are finished with the client (or the client is finished with you):: @@ -559,7 +563,6 @@ are finished with the client (or the client is finished with you):: break data = connstream.read() # finished with client - connstream.close() And go back to listening for new client connections. |