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

Re: [pygame] Networking?



I tried the twisted as separate process thing for a while when i was
working with Blender's game engine.  At the time it was the only way I
knew how to do it, but it was very unwieldy to work with and deploy,
just not a good system at all.  You are already introducing issues
with network communication, why introduce issues with local
communication as well.

Currently I am using sockets with threads, it works pretty well I
think.  It seems extremely stable, and fast enough, if I could get my
higher level constructs in order.  The hard part with network
programming in my opinion is the higher level stuff rather than the
protocol.  How to serialize the data, what data to send, and how to
interpret it, is very difficult if you want a smooth game.  No
networking library I have seen handles this for you.  I'd like to see
someone write a game network library that handles things like moving
characters around and sending chat messages - 95% of networked games
need these two things.  But most games are so specialized and
integrated that it's hard to modularize this functionality to make it
general enough for a library.  If I ever completely solve my netcode,
I don't see myself being up to that task.

I used to really like twisted, but it's sort of a hard nut to crack
sometimes.  When using basically the raw tcp or udp protocols, twisted
seems like massive overkill to me, and none of it's constructs seem
all that well tailored to games.  That might have changed in the few
years I've been away though.  What things like raknet, hawkNL, etc
give you, is the ability for reliable udp sockets, which does make
some things a bit easier and smoother.

But really, the socket module IS everything you need.  It's just a lot
of work to set up and learn to use it.

On Nov 20, 2007 12:49 PM, Richard Jones <richardjones@xxxxxxxxxxxxxxxx> wrote:
> On Wed, 21 Nov 2007, David wrote:
> > 1)  Use Twisted with reactor.iterate
>
> I found that this approach has quite a high impact (ie. takes a considerable
> amount of time to run, even when there's no network events).
>
>
> > 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 is also useless for highly interactive games.
>
>
> >  3) Run the Twisted reactor in its own thread
>
> This is probably the only reasonable approach for games.
>
>
> > 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.
>
> Quite difficult to manage on Windows.
>
>
>      Richard
>