[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] network



On Mon, 28 Jun 2004 07:17:00 -0700, Pete Shinners <pete@shinners.org> wrote:
> When you say you prefer twisted, how are you using it? Isn't it just
> some tool for "send a message", "has a message arrived"? How is that
> better than socket with select? Or if you need, the asyncore module has
> already tied those together for you.

The benefits are more pronounced when writing the server code,
compared to client-side code. Especially things like handling
timeouts, disconnects etc. seems cleaner in Twisted than plain sockets
or even asyncore. Twisted also contains utilities for parsing and
serialization even if you are creating your own, simple message
protocol instead of using some existing one.

But I admit it's somewhat a matter of personal preference too. Once I
got used to the Twisted way of writing socket servers (event-based and
single threaded), it just feels more comfortable and natural than the
alternatives. Asyncore gets you halfway, but there still a bunch of
boring, low-level stuff you'll have to write yourself.
 
Also, if you happen to use some other (existing) protocol like http at
some point in the course of your project, it all integrates together
very nicely.

> The Twisted documentation I've read starts like "you don't write
> applications that use twisted, you write libraries that plugin to it".

This is just propaganda that you can choose to ignore if you wish. :) 
It's quite possible to use Twisted like an ordinary library if you
just want to to create a simple message protocol of your own.

-- 
Sami Hangaslammi