Socket server

Hugo Martires hugomartires at hotmail.com
Wed Jan 23 17:55:52 EST 2002


Ok, i see your point.
I was looking for the SocketServer and asyncore modules. I also try to
understand wat's in the module reference about it and i understand
almost all (the concepts).
I also learn to programming multithread aplications as i read in my
book "Core Python programming" and i think they win my vote.

However i don't know how to implement a multythread server.
Where to start ???
It's a bit complicated.
As i'm a newbie, where i can find a detailed explanation about
creating a MultyThread web server.

Can anyone send me a small example of a server and a client (and the
explanation), just to start ?

Sory again to take your time, but i'm feeling lost in this world of
socket programming.

Tasnks
-----------

Jonathan Gardner <jgardn at alumni.washington.edu> wrote in message news:<mailman.1011303235.23256.python-list at python.org>...
> On Friday 18 January 2002 03:39 am, 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 ?
> >
> 
> "Simple Example" - it's not so simple anymore. Depending on what you want to 
> do, your options are:
> 
> - Forking. Each new call is answered by forking off a child process. The 
> child process does all the work, and when it is done, it dies. This is how 
> Apache does it. You can get it into all kinds of fun problems, like keeping 
> some children alive, telling those children to die after so many times, 
> etc... Your level of complexity depends on what you want.
> 
> - Threading. Each new call is answered with a new thread. This entails all 
> that threading is about. It gives you similar results as the above, except 
> each thread can play with the parent in the way that threads like to do.
> 
> - Multiplexing. You run in a tight loop, waiting until there is something to 
> read or until one of the sockets is ready to write to. The simplest example 
> of this is much more complicated than the above two, but it really isn't that 
> hard. This is the best bet for MUDs and such. And you can't really make it 
> much better. However, windows doesn't treat sockets like files, and so you 
> run into some interesting problems on windows that just aren't issues on a 
> real operating system. (Like, you can run a select call on stdin, stdout, and 
> stderr.)
> 
> Code for each of these abounds on the internet. Take a google search. Look 
> through the modules for SocketServer and its children. You will find the 
> modules remarkable readable, even to a newbie.
> 
> Jonathan



More information about the Python-list mailing list