[Twisted-Python] Using IConnector descendant

Andrew Bennetts andrew-twisted at puzzling.org
Mon Feb 17 21:42:00 EST 2003

On Tue, Feb 18, 2003 at 04:13:37AM +0200, Dmitry Litovchenko wrote:
> Currently I have working SOCKS5-client Protocol, Connector and
> ClientFactory classes. Almost working.
> The question is: when I certainly done and my self.state in protocol
> is "done" and transport pipe is ready, how to switch from SOCKS
> protocol to underlying one?
> 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? +++

Probably something like:
    self.__class__ = self.otherProtocol

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


More information about the Twisted-Python mailing list