Michael Goettsche <[EMAIL PROTECTED]> writes:
> Assuming the server accepts connections in an endless loop, how
> would I handle communication without additional threads and create
> new games in that loop? Could you give me pseudo-code for this?
I've always done this kind of thing with the SocketServer module
and the threading mixin. You'd say something like:
from SocketServer import SocketServer, ThreadingMixin
class Battleship_server(ThreadingMixin, SocketServer):
def handle(self, request):
# this method gets called in a new thread when a new connection
# arrives. Just handle the whole game for that connection here.
You do need some synchronization to avoid concurrency hazards when
the different threads touch shared data (like a global scoreboard)
but it's not as bad as it sounds.
--
http://mail.python.org/mailman/listinfo/python-list