Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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.

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!

If you like C, I heartily recommend libtelnet. It will maintain an internal state that does all the IAC sequence parsing for you, and handles option negotiation using the Q method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top