[Twisted-Python] twisted.conch.telnet example?

Stephen Hansen apt.shansen at gmail.com
Tue Jun 26 11:03:26 MDT 2007


Hello all. :)

I'm trying to learn Twisted, and to replace irritating telnetlib code for a
simple telnet client application to do so. The problem is I'm slightly lost
as to where to start with the twisted.conch.telnet library, so was wondering
if anyone could point me to a simple example.

So far, I understand the whole client factory thing-- but where I start
getting lost is where we get to the "protocol" point (I know I know-- so
early to get confused!).

Specifically, in the buildProtocol method of a ReconnectingClientFactory
instance.. what should I be returning a subclass of?

There's a telnet.Telnet, which /looks/ like it would be handling all of the
telnet negotiation nicely, but it has methods like "def enableRemote" that
call "self.protocol.enableRemote".. and I'm not sure what should be put
there, or how that should have been handled.

My best success so far was to have it return a subclass of
telnet.StatefulTelnetProtocol. It does the "basis" of what I want: a
line-oriented output from the telnet protocol connection. However, it also
returns all the negotiation characters, so it seems like it's not actually
implementing the telnet negotiation part itself.

Then there's telnet.TelnetBootstrapProtocol which looks very interesting but
looks like its mostly handling telnet features I'm not interested in
(various line modes, screen size negotiation, etc) yet... and a
telnet.TelnetProtocol that I'm very confused by.. it's inheriting from
ITelnetProtocol which appears to define the basic negotiation methods, but
it doesn't appear to -do- anything. (And telnet.Telnet, which does
notinherit from that interface, does appear to support -doing- the
negotiation)

This might all be a lot of babbling, and if so-- sorry! I'm just not sure
where to get started on understanding what's going on in this module to make
use of it. :) I tried googling around to see if I could find a simple
display of gluing the conch modules together to produce a line-oriented
telnet client connection that appeared to handle the negotiation ... just to
get started-- and I can't find one. Does anyone know of one? (Or, if I give
you $0.25, could you throw one together? :))

Thanks in advance.

--S
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20070626/b5cb5091/attachment.html>


More information about the Twisted-Python mailing list