[Twisted-Python] Using IConnector descendant

Dmitry Litovchenko kwaker at uch.net
Mon Feb 17 21:36:53 EST 2003

Hello Andrew,

Tuesday, February 18, 2003, 4:42:00 AM, you wrote:

>> Assuming I am inside Protocol object.
>>     def socks_gotConnectReply (self, data):
>>         """ Called after server accepts or rejects CONNECT method.
>>         """
>>         if data[:2] == "\x05\x00":
>>             # IMHO no need to analyze other fields of reply, we are done
>>             #
>>             self.state = "done"
>> +++ what to put here to switch from SOCKS to another protocol? +++

AB> Probably something like:
AB>     self.__class__ = self.otherProtocol
AB>     self.connectionMade()

AB> I don't know anything about SOCKS, but I've used this trick successfully
AB> before, where I had to handshake with one protocol, then switch another
AB> protocol for the rest of the connection.

Cool, this may work, certainly. Thanks a lot.

Is this example repeats the original way, that IConnector inventor
thought everyone will use, or there are other variants?

Best regards,
 Dmitry                            mailto:kwaker at uch.net

More information about the Twisted-Python mailing list