Multithreaded HTTP Server for Linux built up by the pool of threads multiplexing select() system call

Posted by dba477 on Jun 17, 2004 7:49 AM EDT
LXer; By Boris Derzhavets
Mail this story
Print this story

Why “Advanced Linux Programming. New Riders Publishing, 2001” does fork to multiplex I/O building up an example of HTTP Server?

Developing code bellow we follow general guidelines from [1] chapter 11.
The only one source file has been modified is server.c.
Instead of fork new process to handle each incoming client's connection,
as procedure server_run ( ) does in [1], we start pool of 1024 threads
accepting as parameter descriptor of passive socket.
The procedure run by each thread is asynchronous BSD socket's server 
utilizing
select() system call (see for example [2],chapter 13(5)) to switch between 
handling
incoming client's requests by accept() system call and receiving "http" 
requests
from clients already connected to server utilizing procedures
handle_request() and handle_get() from [1],chapter 11.

References

1.Mark Mitchel,Jeffrey Oldham,Alex Samuel. Advanced Linux Programming. New Riders Publishing , 2001. http://www.advancedlinuxprogramming.com

2.Douglas E. Comer,David L. Stevens Internet Working with TCP/IP ,vol 3 Client-Server Programming and application Linux/Posix Socket Version, Prentice Hall,Inc. 2001

View the code here: http://lxer.com/~dave/server.c

  Nav
» Read more about: Story Type: News Story; Groups: LXer

« Return to the newswire homepage

This topic does not have any threads posted yet!

You cannot post until you login.