I hope you mean that the sockets library is not the place to start, simply because it's not immediately easy (unlike Twisted) to get right into? I believe every programmer who wants to use a higher-level library should at least have a stab at the low-level stuff, just to give a better idea of what's going on behind the automagical scenese of things like Twisted Rather than haul in Twisted, a little research on the Python select module could be the very thing people are looking for - all without having any extra dependencies/includes other than the core Python library and Pygame. http://www.amk.ca/python/howto/sockets/ <http://www.amk.ca/python/howto/sockets/ - > - the Non-blocking Sockets section is particularly enlightening If potential socketeers out there are worried about things like byte-order and so on, remember that the IRC protocol is 100% ASCII-based, and whilst it may have its problems here and there, for the most part it's one of the oldest, reliable protocols available (and great to learn from). --- The python sockets library is probably *not* the place to start. It is very primitive, and most references you will read will recommend using a higher level library such as asyncore or (higher yet) asynchat. Unfortunately, these higher level libraries share the same weakness as Twisted, in that that they expect to own the main loop. ---
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of David Sent: Tuesday, November 20, 2007 09:44 To: pygame-users@seul.org Subject: Re: [pygame] Networking? The python sockets library is probably *not* the place to start. It is very primitive, and most references you will read will recommend using a higher level library such as asyncore or (higher yet) asynchat. Unfortunately, these higher level libraries share the same weakness as Twisted, in that that they expect to own the main loop. I have identified five general approaches to integrating networking with a pygame application. I have not fully implemented a game with any of them, .. but soon. 1) Use Twisted with reactor.iterate . This is the easiest approach, and the one that Mr Wittber's library uses. Use of reactor.iterate is unfortunately deprecated by the Twisted developers, and will, presumably, be removed from Twisted in some future release. 2) Use the Twisted reactor *as* your main loop, and implement all game logic as call-backs from there. This is the approach that the Twisted people will recommend. This approach is quite burdensome, in that structuring your game into a series of callbacks can be difficult. Using generators as coroutines provides some relief, in that you can pass the generators 'next' method as a callback to Twisted, and maintain game state within the generator. Using subroutines or nested generators involve their own awkwardnesses. 3) Run the Twisted reactor in its own thread, and use ThreadedSelectReactor to move data to the pygame event queue. Bob Ippolito has blogged on how to use this with Pygame (GIYF). Unfortunately, ThreadedSelectReactor is unmaintained and deprecated. 4) Run the Twisted reactor in its own thread, and use thread-safe queues to move data to and from the main thread. Alternatively, if you wish to use the perspective-broker features or use Twisted code beyond mere message passing, there are tools in Twisted for safely invoking methods in other threads. Hmm. maybe these were deprecated with the TSR? 5) Run the Twisted reactor in its own process, and use pipes or sockets to pass data between it and the main loop/process. This has the merit of using the OS's CPU allocation management rather than that of Python's thread manager. Most of these approaches could use asyncore/asynchat as an alternative to Twisted. My own efforts lately have been along approaches 2 and 5. My engine 'Spyre' will run under Twisted's reactor now, but the getting the whole multi-engine game logic sequence working in the 'inside-out' callback style is an imposing prospect. Philip Hassey has recently released a networked pygame-based game. Has he mentioned what networking approach he used? David On 11/19/07, Jason Ward < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: I want to make my game playable over the network and if possible the internet. For the network it must support more than 2 computers and be realtime Would the sockets library in python solve all my needs? -- [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> Pitcher's Duel -> pitchersduel.python-hosting.com <http://pitchersduel.python-hosting.com> CONFIDENTIAL NOTICE: This email including any attachments, contains confidential information belonging to the sender. It may also be privileged or otherwise protected by work product immunity or other legal rules. This information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on the contents of this emailed information is strictly prohibited. If you have received this email in error, please immediately notify us by reply email of the error and then delete this email immediately.