Greg's suggestion to try to become familiar with Python before trying to take on Twisted is perhaps a reasonable one. Limiting the possible sources of your confusion may help you avoid some very frustrating cases.
On the other hand, I know a lot of people who take on a Twisted-based project as a first Python learning experience, and succeed. So it's possible. And you'll have to do something first. There's no guarantee that what you pick instead of Twisted will be easier. :)
As far as the specifics of telnet go, you want to use twisted.conch.telnet
, not twisted.protocols.telnet
. The former is newer, better tested, more featureful, and has several examples (although unfortunately not a lot of documentation beyond that).
The main telnet example shows you the most useful event handlers you can define if you use twisted.conch.telnet
. Unfortunately it doesn't really explain what they do, nor does it give a demonstration of how you might negotiation options. If you're already familiar with the telnet protocol itself (primarily the option negotiation part of it), this should make sense to you. If you're thinking of "telnet" as just a way to pass human readable/writeable bytes between two computers, then you probably haven't run across option negotiation before and it might not make much sense. You can either ignore it, or check out the telnet RFC to learn more (it's a little dense, though).
For performing option negotiations yourself, you can at least take a look at the API documentation for the self.transport
object you see in the above linked example (this isn't a regular TCP transport as you'll find used throughout much of Twisted, but a special telnet-derived transport which sits on top of TCP, so it has a few extra features).
If you just want to pass bytes around, though, then you can focus on the dataReceived
method and on self.transport.write
. The former will be called when you receive bytes from your peer; the latter you can call to send bytes to your peer.