Commit 95826667 authored by Antoine Pitrou's avatar Antoine Pitrou

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.
........
parent f84a50ae
...@@ -515,6 +515,9 @@ The module :mod:`socket` exports the following constants and functions: ...@@ -515,6 +515,9 @@ The module :mod:`socket` exports the following constants and functions:
Module :mod:`SocketServer` Module :mod:`SocketServer`
Classes that simplify writing network servers. Classes that simplify writing network servers.
Module :mod:`ssl`
A TLS/SSL wrapper for socket objects.
.. _socket-objects: .. _socket-objects:
...@@ -551,6 +554,12 @@ correspond to Unix system calls applicable to sockets. ...@@ -551,6 +554,12 @@ correspond to Unix system calls applicable to sockets.
remote end will receive no more data (after queued data is flushed). Sockets are remote end will receive no more data (after queued data is flushed). Sockets are
automatically closed when they are garbage-collected. automatically closed when they are garbage-collected.
.. note::
:meth:`close()` releases the resource associated with a connection but
does not necessarily close the connection immediately. If you want
to close the connection in a timely fashion, call :meth:`shutdown()`
before :meth:`close()`.
.. method:: socket.connect(address) .. method:: socket.connect(address)
......
:mod:`ssl` --- SSL wrapper for socket objects :mod:`ssl` --- TLS/SSL wrapper for socket objects
============================================= =================================================
.. module:: ssl .. module:: ssl
:synopsis: SSL wrapper for socket objects :synopsis: TLS/SSL wrapper for socket objects
.. moduleauthor:: Bill Janssen <bill.janssen@gmail.com> .. moduleauthor:: Bill Janssen <bill.janssen@gmail.com>
...@@ -588,7 +588,11 @@ for it:: ...@@ -588,7 +588,11 @@ for it::
certfile="mycertfile", certfile="mycertfile",
keyfile="mykeyfile", keyfile="mykeyfile",
ssl_version=ssl.PROTOCOL_TLSv1) ssl_version=ssl.PROTOCOL_TLSv1)
try:
deal_with_client(connstream) 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 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):: are finished with the client (or the client is finished with you)::
...@@ -604,7 +608,6 @@ are finished with the client (or the client is finished with you):: ...@@ -604,7 +608,6 @@ are finished with the client (or the client is finished with you)::
break break
data = connstream.read() data = connstream.read()
# finished with client # finished with client
connstream.close()
And go back to listening for new client connections. And go back to listening for new client connections.
......
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