I've implemented an efficient windows server using IO completion ports, and now I need to implement a new, cross platform one - Probably using select
My design in Windows is based on X worker threads that get the messages out of the IO completion port queue, where X is a number dependent on the hardware and project properties.
In linux, however, there is no IO Completion Port. I'd like to keep my design / use a leader-follower design for accepting or reading from the sockets. I've looked around a bit, and it seems select is kinda the only way.
(If I understand correctly, using select is equivalent to using WaitForMultipleObjects) So my design should be something like:
- Create a thread pool
- All threads wait on a select function, with all client sockets read handles, and the listen socket accept handle.
- When a new socket connects, somehow alert the other threads to update their handles for the select function
Breaking the select to update for a new client seems a bit superficial. Is there a better way?
Can someone point me to an example of an high-performance implementation of a socket server?