[Twisted-Python] Custom transports

Christopher Armstrong radeex at gmail.com
Fri Dec 23 22:17:39 EST 2005

On 12/24/05, Itamar Shtull-Trauring <itamar at itamarst.org> wrote:
> On Thu, 2005-12-22 at 18:34 -0500, Adam Atlas wrote:
> > Hello,
> >
> > What would I do to implement a custom transport within the Twisted
> > framework? That is, I'd like to be able to add custom listen___ and
> > connect___ methods to the reactor, so that existing protocols can run
> > over a new backend transport protocol. What API would I use for this?
> If this transport is implemented in terms of other protocols, it doesn't
> have to be a reactor method. For example, lets say you write a SOCKSv4
> transport; the way users would use it is probably:
> mySocksProxy = SOCKSProxy('myproxy.example.com', 9999)
> mySocksProxy.listenTCP(8080, SomeFactory())
> Even if it requires registering file descriptors, you don't *have* to
> add reactor.* methods (see e.g. twisted.internet.stdio).

Also, the reactor has a method listenWith that may be useful. See the
docs for it in twisted.internet.interfaces.

  Twisted   |  Christopher Armstrong: International Man of Twistery
   Radix    |    -- http://radix.twistedmatrix.com
            |  Release Manager, Twisted Project
  \\\V///   |    -- http://twistedmatrix.com
   |o O|    |

More information about the Twisted-Python mailing list