I wish to know how does an Apache HTTP server program serves many clients connecting to it at the same port 80? I know about port and sockets. I did lot of search on internet about it but could not find an answer that explains it most simply. Many answers raises new questions, like this one:
Normally, for every connecting client the server forks a child process that communicates with the client (TCP). The parent server hands off to the child process an established socket that communicates back to the client. When you send the data to a socket from your child server, the TCP stack in the OS creates a packet going back to the client and sets the "from port" to 80. If a server uses only a single child-process to serve all the sockets then the server is called single-process/threaded and if the server uses many sub-processes to serve each socket by one sub-process then the server is called multi-process/threaded server. Note that irrespective of the server's type a server can/should always uses the same initial socket to respond back (no need to allocate another server-port).
Is Apache HTTP server multithreaded or a single threaded? My guess is that it is multithreaded.
In case of persistent connection, how does client computer contacts its child process again? is there a table or something maintained by parent process to map the client to its child process? or a new child process is created everytime? What is the life-cycle of a child process?