summaryrefslogtreecommitdiff
path: root/Doc/library/asyncore.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/asyncore.rst')
-rw-r--r--Doc/library/asyncore.rst24
1 files changed, 13 insertions, 11 deletions
diff --git a/Doc/library/asyncore.rst b/Doc/library/asyncore.rst
index 619b7bb639..1521e72533 100644
--- a/Doc/library/asyncore.rst
+++ b/Doc/library/asyncore.rst
@@ -53,10 +53,10 @@ any that have been added to the map during asynchronous service) is closed.
channels have been closed. All arguments are optional. The *count*
parameter defaults to None, resulting in the loop terminating only when all
channels have been closed. The *timeout* argument sets the timeout
- parameter for the appropriate :func:`select` or :func:`poll` call, measured
- in seconds; the default is 30 seconds. The *use_poll* parameter, if true,
- indicates that :func:`poll` should be used in preference to :func:`select`
- (the default is ``False``).
+ parameter for the appropriate :func:`~select.select` or :func:`~select.poll`
+ call, measured in seconds; the default is 30 seconds. The *use_poll*
+ parameter, if true, indicates that :func:`~select.poll` should be used in
+ preference to :func:`~select.select` (the default is ``False``).
The *map* parameter is a dictionary whose items are the channels to watch.
As channels are closed they are deleted from their map. If *map* is
@@ -184,12 +184,15 @@ any that have been added to the map during asynchronous service) is closed.
Most of these are nearly identical to their socket partners.
- .. method:: create_socket(family, type)
+ .. method:: create_socket(family=socket.AF_INET, type=socket.SOCK_STREAM)
This is identical to the creation of a normal socket, and will use the
same options for creation. Refer to the :mod:`socket` documentation for
information on creating sockets.
+ .. versionchanged:: 3.3
+ *family* and *type* arguments can be omitted.
+
.. method:: connect(address)
@@ -205,7 +208,8 @@ any that have been added to the map during asynchronous service) is closed.
.. method:: recv(buffer_size)
Read at most *buffer_size* bytes from the socket's remote end-point. An
- empty string implies that the channel has been closed from the other end.
+ empty bytes object implies that the channel has been closed from the
+ other end.
.. method:: listen(backlog)
@@ -274,13 +278,13 @@ asyncore Example basic HTTP client
Here is a very basic HTTP client that uses the :class:`dispatcher` class to
implement its socket handling::
- import asyncore, socket
+ import asyncore
class HTTPClient(asyncore.dispatcher):
def __init__(self, host, path):
asyncore.dispatcher.__init__(self)
- self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.create_socket()
self.connect( (host, 80) )
self.buffer = bytes('GET %s HTTP/1.0\r\nHost: %s\r\n\r\n' %
(path, host), 'ascii')
@@ -314,7 +318,6 @@ Here is a basic echo server that uses the :class:`dispatcher` class to accept
connections and dispatches the incoming connections to a handler::
import asyncore
- import socket
class EchoHandler(asyncore.dispatcher_with_send):
@@ -327,7 +330,7 @@ connections and dispatches the incoming connections to a handler::
def __init__(self, host, port):
asyncore.dispatcher.__init__(self)
- self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.create_socket()
self.set_reuse_addr()
self.bind((host, port))
self.listen(5)
@@ -338,4 +341,3 @@ connections and dispatches the incoming connections to a handler::
server = EchoServer('localhost', 8080)
asyncore.loop()
-