[Twisted-Python] Using IConnector
Bob Ippolito
bob at mastersofbranding.com
Tue Feb 18 13:28:02 MST 2003
On Tuesday, Feb 18, 2003, at 14:45 America/New_York, Dmitry Litovchenko
wrote:
> I certainly need a brief sample of how to use reactor.connectWith and
> how to set up Protocol so that it correctly switches to another
> Protocol and initializes it.
>
> Example with:
>
> self.__class__ = anotherProto.__class__
> self.connectionMade()
>
> is good but not enough. Constructor must be called at least and
> parameters should be passed to it.
>
> If I solve this problem in my way this may be incompatible with the
> whole Twisted ideology, which I currently don't know well. But I need
> to know the right way because I intend to create SOCKS 4, 5 and HTTP
> tunnel modules not for my use only but to contribute to Twisted.
>
> Please advise, I don't want to produce working code that works for me
> only while violating ten tons of Twisted conventions that are
> undocumented and invisible for me.
Ok, well, I can't speak for this part of twisted.. but I *think* the
proper way would be to make it a Transport, not a Protocol. For
example, if you were behind a stupid firewall and you wanted to make
connections to another host outside of the firewall, you would have to
refactor a lot less code if it could just be a transport.
Just an idea, again, I'm not an authority on this in any way.
-bob
More information about the Twisted-Python
mailing list