I am making a simple multiplayer economic game in pygame. It consists of turns of a certain length, at the end of which, data is sent to the central server. A few quick calculations are done on the data and the results are sent back to the players. My question is how I should implement the network support. I was looking at Twisted and at Pyro and any suggestions or advice would be appreciated.
+3
A:
Twisted would certainly be a good idea. Here is example code that integrates twisted and pygame.
nosklo
2009-08-09 11:49:52
Yay for Twisted!
Alex Martelli
2009-08-09 15:28:36
Twisted rocks :)
zebrabox
2009-08-10 11:23:38
A:
I've nothing against Twisted and PyRo, but the sort of simple messages you're going to be sending don't require anything like that and might be overcomplicated by using some sort of framework. Pickling an object and sending it over a socket is actually a very easy operation and well worth trying, even if you do eventually go with a more heavyweight framework. Don't fear the network!
Kylotan
2009-08-10 14:23:19
Using pickle for network protocols is an *extremely bad* idea. Here are two recent examples of this:http://plone.org/products/plone/security/advisories/cve-2007-5741http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0668
Jean-Paul Calderone
2009-08-20 21:14:27
Yes, that's a very valid point regarding pickle. I stand by my assertion that performing a trivial serialisation and handling the networking yourself is a good idea though. Does Python offer no standard capability for pure serialisation of data without potential side-effects?
Kylotan
2009-08-21 11:05:32
@Kylotan: Just use twisted and you're done. What's really "overcomplicated" is to try to rewrite what twisted does by hand. Twisted is a complicated, well written and tested piece of code, trying to replicate it yourself almost cetainly means that you'll end up with a half-working, half-baked poor-quality code. Dealing with network is much more than opening a raw low-level socket and naively pushing data. Don't fear the framework!!
nosklo
2009-09-26 22:53:08
I can't say I agree, sorry! Twisted is a convoluted piece of software with a rather idiosyncratic set of terminology and its own set of significant problems (eg. http://twistedmatrix.com/trac/ticket/3901). I prefer Python overall, but I would still prefer to write my own networking layer in C than to use Twisted. Networking is really not as complicated as people fear it is.
Kylotan
2009-09-27 00:03:16