Still on my server program...
The original flow chart consisted of the following:
- Setting up a connection and listen()ing for requests.
I've spent the last couple of days researching my options for threading, and it seemed as though the best option would be to include a third-party library, which I really wanted to avoid, so I had another idea:
- In a loop, accept()ing requests and sending them to a new thread for processing.
- Setting up a connection and listen()ing for requests.
I would of course specify a much larger number of connections to be allowed to wait to be accepted to make up for having one thread of execution.
- In a loop, accept()ing requests and processing them right there in the same thread.
My logic is that even though only one request could be processed at a time, it wouldn't affect performance because not having to share processor time with any other thread would make up for that. I also wouldn't have to worry about thread-safety with any resources that I use.
I am of course, not only really tired, but also an idiot. Is my logic flawed? Do you have any advice? This solution just seems to good to be true.
Thanks in advance,
Sean.