Rename create_transport() to create_connection(). Remove type argument.
This commit is contained in:
parent
bc14612a44
commit
d5374ae4cc
50
pep-3156.txt
50
pep-3156.txt
|
@ -295,49 +295,57 @@ Some methods in the standard conforming interface return Futures:
|
||||||
on success will be a tuple ``(host, port)``. Same implementation
|
on success will be a tuple ``(host, port)``. Same implementation
|
||||||
remarks as for ``getaddrinfo()``.
|
remarks as for ``getaddrinfo()``.
|
||||||
|
|
||||||
- ``create_transport(protocol_factory, host, port, **kwargs)``.
|
- ``create_connection(protocol_factory, host, port, **kwargs)``.
|
||||||
Creates a transport and a protocol and ties them together. Returns
|
Creates a stream connection to a given host and port. This creates
|
||||||
a Future whose result on success is a (transport, protocol) pair.
|
an implementation-dependent Transport to represent the connection,
|
||||||
The protocol is created by calling ``protocol_factory()`` without
|
then calls ``protocol_factory()`` to instantiate (or retrieve) the
|
||||||
arguments(*). Note that when the Future completes, the protocol's
|
user's Protocol implementation, and finally ties the two together.
|
||||||
``connection_made()`` method has not yet been called; that will
|
(See below for the definitions of Transport and Protocol.) The
|
||||||
happen when the connection handshake is complete. When it is
|
user's Protocol implementation is created or retrieved by calling
|
||||||
impossible to connect to the given host and port, the Future will
|
``protocol_factory()`` without arguments(*). The return value is a
|
||||||
raise an exception instead.
|
Future whose result on success is the ``(transport, protocol)``
|
||||||
|
pair; if a failure prevents the creation of a successful connection,
|
||||||
|
the Future will have an appropriate exception set. Note that when
|
||||||
|
the Future completes, the protocol's ``connection_made()`` method
|
||||||
|
has not yet been called; that will happen when the connection
|
||||||
|
handshake is complete.
|
||||||
|
|
||||||
(*) There is no requirement that ``protocol_factory`` is a class.
|
(*) There is no requirement that ``protocol_factory`` is a class.
|
||||||
If your protocol class needs to have specific arguments passed to
|
If your protocol class needs to have specific arguments passed to
|
||||||
its constructor, you can use ``lambda`` or ``functools.partial()``.
|
its constructor, you can use ``lambda`` or ``functools.partial()``.
|
||||||
|
You can also pass a trivial ``lambda`` that returns a previously
|
||||||
|
constructed Protocol instance.
|
||||||
|
|
||||||
Optional keyword arguments:
|
Optional keyword arguments:
|
||||||
|
|
||||||
- ``family``, ``type``, ``proto``, ``flags``: Address familty,
|
- ``family``, ``proto``, ``flags``: Address familty,
|
||||||
socket type, protcol, and miscellaneous flags to be passed through
|
protcol, and miscellaneous flags to be passed through
|
||||||
to ``getaddrinfo()``. These all default to ``0`` except ``type``
|
to ``getaddrinfo()``. These all default to ``0``.
|
||||||
which defaults to ``socket.SOCK_STREAM``.
|
(The socket type is always ``SOCK_STREAM``.)
|
||||||
|
|
||||||
- ``ssl``: Pass ``True`` to create an SSL transport (by default a
|
- ``ssl``: Pass ``True`` to create an SSL transport (by default a
|
||||||
plain TCP is created). Or pass an ``ssl.SSLContext`` object to
|
plain TCP is created). Or pass an ``ssl.SSLContext`` object to
|
||||||
override the default SSL context object to be used.
|
override the default SSL context object to be used.
|
||||||
|
|
||||||
TBD: Should this be called create_connection()?
|
|
||||||
|
|
||||||
- ``start_serving(protocol_factory, host, port, **kwds)``. Enters a
|
- ``start_serving(protocol_factory, host, port, **kwds)``. Enters a
|
||||||
loop that accepts connections. Returns a Future that completes once
|
loop that accepts connections. Returns a Future that completes once
|
||||||
the loop is set up to serve; its return value is None. Each time a
|
the loop is set up to serve; its return value is None. Each time a
|
||||||
connection is accepted, ``protocol_factory`` is called without
|
connection is accepted, ``protocol_factory`` is called without
|
||||||
arguments(*) to create a protocol, a transport is created to represent
|
arguments(*) to create a Protocol, a Transport is created to represent
|
||||||
the network side of the connection, and the two are tied together by
|
the network side of the connection, and the two are tied together by
|
||||||
calling ``protocol.connection_made(transport)``.
|
calling ``protocol.connection_made(transport)``.
|
||||||
|
|
||||||
(*) See footnote above for ``create_transport()``.
|
(*) See footnote above for ``create_connection()``. However, since
|
||||||
|
``protocol_factory()`` is called once for each new incoming
|
||||||
|
connection, it is recommended that it return a new Protocol object
|
||||||
|
each time it is called.
|
||||||
|
|
||||||
Optional keyword arguments:
|
Optional keyword arguments:
|
||||||
|
|
||||||
- ``family``, ``type``, ``proto``, ``flags``: Address familty,
|
- ``family``, ``proto``, ``flags``: Address familty,
|
||||||
socket type, protcol, and miscellaneous flags to be passed through
|
protcol, and miscellaneous flags to be passed through
|
||||||
to ``getaddrinfo()``. These all default to ``0`` except ``type``
|
to ``getaddrinfo()``. These all default to ``0``.
|
||||||
which defaults to ``socket.SOCK_STREAM``.
|
(The socket type is always ``SOCK_STREAM``.)
|
||||||
|
|
||||||
TBD: Support SSL? I don't even know how to do that synchronously,
|
TBD: Support SSL? I don't even know how to do that synchronously,
|
||||||
and I suppose it needs a certificate.
|
and I suppose it needs a certificate.
|
||||||
|
|
Loading…
Reference in New Issue