[Twisted-Python] Two-way telnet client problem

Jean-Paul Calderone exarkun at divmod.com
Fri Apr 10 12:06:34 EDT 2009

On Thu, 9 Apr 2009 02:34:23 -0400, Greg Taylor <gtaylor at clemson.edu> wrote:
>Hello all,
>I'm still pretty new with Twisted, so the documentation is a little
>bit cryptic and strange to wade through. I'm writing a MUD server that
>I'd like to add InterMUD Protocol (IMC) to. This basically allows any
>of the games running the MUD server to connect to an IMC server that
>lets players from other games talk to one another. I'm thinking I'll
>create another thread and run the IMC client from there so as to not
>block the main server thread.

Threading generally isn't the way to do networking with Twisted.  In fact,
Twisted is almost wholly geared toward avoiding exactly that.

>From your example, it appears as though you've figured out how to do basic
client setup.  What you're missing is how to use the connection once it
is established.  You need to be thinking of your program in terms of events.

> [snip]
>I've seen mention of something like:
>p = reactor.buildProtocol()

You can't really do this.  Instead, it seems that since you want to send
a line once the connection is established, you should be putting code into
the event handler for "connection is established".  Your example code
already defined behavior for this event, in fact - but you only put a
print statement into it.  Try expanding your `connectionMade´ method to
do the other things you want to happen at connection setup time.


More information about the Twisted-Python mailing list