Multithreaded HTTP Server for Linux built up by the pool of threads multiplexing select() system call
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  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 , 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
select() system call (see for example ,chapter 13(5)) to switch between
incoming client's requests by accept() system call and receiving "http"
from clients already connected to server utilizing procedures
handle_request() and handle_get() from ,chapter 11.
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
This topic does not have any threads posted yet!
You cannot post until you login.