Socket to me
Andrew Bennetts
andrew-pythonlist at puzzling.org
Sat May 31 10:08:55 EDT 2003
On Sat, May 31, 2003 at 03:18:38PM +0200, Irmen de Jong wrote:
> Mark Carter wrote:
>
> >Has anyone implemented a telnet daemon in python?
>
> Twisted probably has ;-)
Oh, yes, I forgot to answer this part :)
Twisted does indeed have a telnet server!
A quick and dirty example:
bash-2.05b$ mktap telnet --port 1234 --username=bilbo --password=baggins
bash-2.05b$ twistd -f telnet.tap
bash-2.05b$ telnet localhost 1234
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
twisted.manhole.telnet.ShellFactory
Twisted 1.0.5
username: bilbo
password: *****
>>> print "Welcome to Python over telnet :)"
Welcome to Python over telnet :)
>>> from twisted.internet import reactor
>>> reactor.stop()
>>> Connection closed by foreign host.
bash-2.05b$
As you can see, the telnet server is written to just give you a python
prompt into your program (handy for debugging).
More impressively, there's Conch, our SSH implementation:
bash-2.05b$ sudo mktap conch -d /etc/ssh --port 5822
bash-2.05b$ sudo twistd -f conch.tap
bash-2.05b$ ssh -p 5822 localhost
andrew at localhost's password:
andrew at frobozz:~$ # Tada!
andrew at frobozz:~$ exit
logout
Connection to localhost closed.
There's a reasonably up-to-date list of protocols we have already written
for you at:
http://twistedmatrix.com/products/protocols
-Andrew.
More information about the Python-list
mailing list