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

Jarosław Fedewicz jaroslaw.fedewicz at gmail.com
Mon Aug 14 18:22:36 MDT 2017


Recently, I needed to write a client for a server which can listen on one
of these:

1) TCP
2) UDP
3) Unix stream sockets
4) Unix datagram sockets

And pain it was, as a matter of fact. The only thing that was easy was the
streaming protocols part. In the datagram land, it was all different:

1) I had to cope with a fact that transport.connect() only really works
with UDP, and employ a workaround which allowed me to use the same protocol
class for both UDP and Unix datagrams
2) setting up client for UDP and datagram is a wildly different procedure:
for Unix datagram sockets, I use reactor.connectUNIXDatagram(), for UDP I
need to use reactor.listenUDP(0, ...) which is fairly confusing to say the
least
3) endpoints, for some reason, with connection parameters as strings, and
unified connection routine do not exist for datagram protocols at all
4) it seems either impossible or really hard to create a transport-agnostic
protocol (with the bulk of logic defined on an upper layer, and
framing/messaging defined at the transport level protocol classes), which
could be connected to any endpoint it supports, using clientFromString() or
serverToString().

The number of protocols that use TCP or UDP interchangeably is quite high.
Some applications where Twisted would be an appropriate choice, could even
work with non-TCP/UDP transports, like QUIC, DCCP, STCP, etc.

(I haven't even looked at the issue of lower layers or other address
families yet, there be dragons.)

My question is: does anyone share my pain? Is there some kind of ongoing
effort to design an API or anything else? What can I do to help?

-- 
Yaroslav Fedevych
IT Philosopher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20170815/a108cb59/attachment.html>


More information about the Twisted-Python mailing list