tags:

views:

502

answers:

5

I'm looking to start a MUD client application, which connects to a MUD hosted on a telnet server. The only thing important to me is that it runs painlessly and efficiently across any OS. Aside from that requirement, I'm not really sold on any language.

So I'm looking for a freely available telnet client library on which I can base my application, so I don't have to deal with the details of the protocol too much.

+7  A: 

I would always consider Twisted for this kind of thing (Python).

The beauty is that if you later decide to swap it out to SSH or anything more secure than telnet, you can with little pain.

Ali A
I can't really find any good examples for using Telnet with Twisted, can you?
Ray
It's just like using any other Twisted "protocol". You will have to look at the examples page eg: http://twistedmatrix.com/projects/core/documentation/howto/clients.html. The protocol you will be using is twisted.conch.telnet.Telnet (not EchoProtocol).
Ali A
API here: http://twistedmatrix.com/documents/8.1.0/api/twisted.conch.telnet.html
Ali A
Yea I've seen each of these, just not any functional telnet client examples...
Ray
+1 for Twisted when writing IP clients/server
orip
+2  A: 

There is a telnet interface in CPAN if you like Perl. It's pretty minimal, but it should get the job done.

[edit] libcurl is also supposed to be able to do telnet, although I couldn't find any examples of it.

charlesbridge
+2  A: 

For all of my MUD programming, I just created my own routines from the ground up using the RFCs.

In case you'd like to avoid some of my pain, I wrapped it up into a fairly simple C# class that handles Telnet properly. In case you'd like to peruse it, you can view it here.

This code has been copy/pasted and run on Windows and on Linux (through Mono) on a handful of separate projects and works pretty good.

HanClinto
Thanks, but I'd prefer something a little more... native.
Ray
+3  A: 

Twisted, twisted, twisted!

To use telnet, see package twisted.conch.telnet. It's got some spartan API docs, but the real information on using it comes from searching on Google Code Search, such as this nugget from grailmud - a MUD server.

orip
A: 

pmc ( http://sourceforge.net/projects/perlmudclient/ ) was an attempt to do exactly this. I've spent some of the last week going through it; it uses an older modified version of Net::Telnet to do its connectivity work.

My problem is that Net::Telnet seems to have a blocking interface when a partial line is sent by the server, i.e. a line not terminated by a newline. It has two features that support this (waitfor and its prompt mechanism), because almost all telnet servers have prompts that are not newline-terminated.

MUDs often have "prompts" that are non-standard and vary through the course of the game; the MUD I admin on has a "Your choice: " prompt as its login [it's not just for usernames], and many game features present alternative prompts. So I suspect you'll need to bear this in mind when you go looking for a cross-platform Telnet library!

Jeremy Smyth