[Twisted-Python] Switch Protocols mid Connection
![](https://secure.gravatar.com/avatar/cc0289b533479bec41acea7ca0cbcc76.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/869963bdf99b541c9f0bbfb04b0320f1.jpg?s=120&d=mm&r=g)
On Sun, 16 Sep 2018 at 16:02, Randall Smith <randall@tnr.cc> wrote:
You might be able to get away with http://bazaar.launchpad.net/~glyph/%2Bjunk/amphacks/annotate/head%3A/python/...
![](https://secure.gravatar.com/avatar/869963bdf99b541c9f0bbfb04b0320f1.jpg?s=120&d=mm&r=g)
On Sun, 16 Sep 2018 at 16:02, Randall Smith <randall@tnr.cc> wrote:
You might be able to get away with http://bazaar.launchpad.net/~glyph/%2Bjunk/amphacks/annotate/head%3A/python/...
participants (3)
-
Glyph
-
Randall Smith
-
Tristan Seligmann