I have not tested the code, but if your port is taking too long to close, you might look at your OS. On Solaris notably prior to tweaking the network stack connections can take a long time to clear, even if closed cleanly. I would start there. If after tweaking your stack, you are still having issues, you might try something along the lines of spawning say 5 kids, then as requests come in pass the work to a child, and if you have less than 5 kids, spawn enough to get back up to 5. Then in the children have them keep track of how many times they have received requests, and die after fulfilling X requests.
Just some random thoughts..
/* And the Creator, against his better judgement, wrote man.c */ | [reply] |