[Twisted-Python] Is there a nice way to write transport-agnostic protocols and servers/clients?

Jean-Paul Calderone exarkun at twistedmatrix.com
Wed Aug 16 15:24:38 MDT 2017


On Wed, Aug 16, 2017 at 9:59 AM, Tristan Seligmann <mithrandi at mithrandi.net>
wrote:

> On Wed, 16 Aug 2017 at 15:28 Kevin Conway <kevinjacobconway at gmail.com>
> wrote:
>
>> Maybe I misunderstand the issue, but I believe the Endpoints API solves
>> for this. https://twistedmatrix.com/documents/16.4.1/core/howto/
>> endpoints.html
>>
>> This abstracts the transport and allows you to focus on only interpreting
>> the bytes transmitted over that transport by defining a Protocol and a
>> Factory that plug into strports. This should allow you to have the business
>> logic defined in only one location while listening/requesting over
>> different transports.
>>
> There is no datagram endpoints API as yet, though (see #4471), only stream
> endpoints.
>
>
Also, when there are datagram endpoints, they won't be compatible with
stream endpoints.  Endpoints don't abstract the transport, they abstract
*creating* the transport.

Twisted provides a uniform abstraction over stream-based transports like
TCP and gives you *ITransport* to implement an *IProtocol* against.  It
also provides a uniform abstraction over datagram-based transports like UDP
and gives you *IUDPTransport* (oops; should have been *IDatagramTransport* and
some other things about it should probably be changed too) to implement a
*DatagramProtocol* (oops; no interface for this one, just subclass: see,
this should change) against.  But it doesn't provide a uniform abstraction
over both stream-based and datagram-based transports.

Implementing such a thing may be possible and even a good idea but no one
has yet done it for Twisted (as far as I know).

Jean-Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20170816/85223c55/attachment-0002.html>


More information about the Twisted-Python mailing list