From: “Dale M.” [email protected]
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.
For what it’s worth… I have some ANSI/VT100 telnet libraries that
partitioning the display into horizontal scrolling regions, and some
full featured line-editing handling insert, delete, scrolling long
history, scrollback buffers with PgUp/PgDn, etc…
Part of this project:
The relevant files would be:
On the plus side, they have unit tests. And on the plus side, each
is relatively loosely coupled… On the downside, the lowest level
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
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 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,