[Twisted-Python] Switch Protocols mid Connection

Randall Smith randall at tnr.cc
Sun Sep 16 08:02:02 MDT 2018


I'm new to Twisted and really enjoying the event driven approach, 
especially with the availability of in-line callbacks to avoid callback 
hell.  So thanks to all of you who have worked on Twisted.

The program I'm writing uses AMP for peer to peer communication. I like 
AMP because it's natively asynchronous, has multi-language support, and 
efficient, not wasting resources on HTTP headers, etc.  There are times 
when I need to send files, 1-2 MB over the connection.  AMP provides a 
binary type, but it's limited to 64k, so I'd have to split the files up 
and make 16+ calls to transfer a single file.  So I need to switch to a 
more appropriate (not yet determined) protocol for the transfer, and 
then back to AMP.  AMP provides a protocol switch command, which is 
great, but then I'd need to switch back to AMP and I have no idea what 
approach to take here.  It  doesn't help that I don't have a file 
transfer protocol selected.

Speaking of file transfer protocol , Twisted's FTP seems like overkill 
for my simple scenario, though if I could harness the functionality I 
need, I'd use it.  I've also read up on Twisted's Producer/Consumer 
approach, which I'm thinking if I have to roll my own, this is the path 
I should take.  However, I surely can't be the first person in more than 
a decade to want to transfer a file while speaking AMP.

So, how do I switch back from a file transfer protocol to AMP and what 
existing protocol, if any, should I use for the transfer?

Thanks so much.

-Randall


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3984 bytes
Desc: S/MIME Cryptographic Signature
URL: </pipermail/twisted-python/attachments/20180916/0de11028/attachment.bin>


More information about the Twisted-Python mailing list