From: "Dale Martenson" <devlists-ruby-talk / devlists.com>
>
> Does anyone know of a Telnet Server written purely in Ruby? It doesn't  
> have to be fully featured. I just need a remote shell for control of an  
> application that I am working on. Telnet is the preferred method since  
> the users of the system are used to using Telnet for network application  
> control and allows simple scripting via a socket.
> 
> I thought about writing my own using GServer and IO.popen, but before  
> embark on that I wanted to avoid re-inventing the wheel.

Hi,

For what it's worth... I have some ANSI/VT100 telnet libraries that support
partitioning the display into horizontal scrolling regions, and some reasonably
full featured line-editing handling insert, delete, scrolling long lines, command
history, scrollback buffers with PgUp/PgDn, etc...

Part of this project:
http://rubyforge.org/cgi-bin/viewvc.cgi/dorkbuster/dbcore/?root=dorkbuster

The relevant files would be:
ansi.rb
ansi-term.rb
term-keys.rb
windowed-term.rb
line-edit.rb

On the plus side, they have unit tests.  And on the plus side, each module
is relatively loosely coupled... On the downside, the lowest level module,
buffered-io.rb, uses kind of a weird approach I developed back under
ruby 1.6.8 when nonblocking I/O wasn't well-supported on win32 ruby,
and so buffered-io was an experiment that technically works (it runs over
thirty servers now, for years with no problems); but it's more
complicated than it needs to be.

These days, instead of buffered-io, I'd have likely started with something
something like the EventMachine library JEGII mentioned in his reply
on this thread.

But anyway, that said, ansi-term only relies on a few methods of
the buffered-io object passed into it, mainly #send_nonblock,
#recv_nonblock, and #recv_ready? ... hmm, also #eof, #peeraddr,
#wait_recv_ready, #flush ...  It might not be _too_ hard to adapt.

Well ... anyway, maybe the code might be of some use, even if
it could take some massaging to fit into a different I/O model.

The license for the source files mentioned here is LGPL preferably,
or Ruby's license if LGPL won't work for you.


Hope this helps,

Bill