March 31st, 2002, 02:09 PM
I've been asked this question by a friend, and since I don't know the answer, I was wondering if any of you could help.
Assume that there's a service, say a web server, listening on a particular port, in this case 80 then, what would the service do if it gets multiple requests at the same time? Say if both you and I access the site at the same time, how does the service handle the requests (as it has only one available port)?
March 31st, 2002, 07:06 PM
The service handles requests by spawning another process that handles your request (forking). Its like, if you go to a bank, the security guard points you to a teller. The security guard would be the "main" program (the program on port 80), and the teller would be the forked program (the spawn of the main program on another port). Spawned processes are given some arbitrarily high-numbered port, so they don't interfere with other processes. So, if 5 people go to a website, the main program will fork 5 spawned processes to accommodate each person.
Note - If a webserver never spawned other processes, it would only have 1 port to send/recieve information from. This means it would only support 1 person on its webpage.
Feel free to email me if you have any further questions!
Stretch your MIND