Writing a small battleship game server in Python

Michael Goettsche mail at tuxipuxi.org
Fri Aug 12 09:39:25 EDT 2005


On Thursday 11 August 2005 18:34, Dan wrote:
> > The server should accept connections from new players and be able to
> > handle multiple games concurrently.
>
> Multiple threads would be the way to go for a real application. But if
> you want to avoid the complexity involved in threading and
> synchronization in this exercize, you can avoid threads by using
> "select" instead:
>   http://www.python.org/doc/2.3.5/lib/module-select.html
>
> The "select" function allows you to determine (without blocking) which
> sockets have input available.
>
> Python's "select" is a wrapper for the C function with the same name. On
> Unix you can learn more about it using "man select".
>

Thanks Dan.
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?

Thanks,
Michael.
 



More information about the Python-list mailing list