Socket server

Michel Van den Bergh vdbergh at luc.ac.be
Thu Jan 17 17:18:04 EST 2002


Hugo Martires wrote:

> I have a server that answer a single client, but now i need moore
> clients.
>
> Witch is the best way to make a server socket that answer's the call's
> of many clients ?
> I have to use threads ? Queues ?
>
> Can any one send me a simple example ?
>
> Tanks !!!

Just wrote a multithreaded server to allow a number of clients to execute

python statements in the same restricted environment. It also includes.
chatting. If found it is really easy. Less than 100 lines of code.

server does the usual bind listen accept cycle, creating a new handler
thread
for each connect. server also creates a single RLock object which is
passed
to handlers to synchronize access to restricted python environment. I
also use
select to circumvent the problem that there is no timeout on accept.

Advice. Just sit down with the manuals and code. It is really easy.

Regards,
Michel






More information about the Python-list mailing list