It is an interesting issue because the are different way to do the job. Take a look at this discussion at
stackoverflow. Another interesting way is CGI as described in this
tutorial. By the way multi threading is absolut necessary.
Please publish an article about your results because I am interested to extend my knowledge.