Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asynchronous I/O on Mac OS X

Meaning the C10K problem, what is the best way to do asynch I/O on Mac OS X (assume to use on Mac and iPhone/iPad)?

On Linux our choice is epoll, on Windows is I/O Completion Ports.

Top priority is performance and scalability (thousands of connections).

UPDATE

OK. As Darwin is BSD-like system, my common idea is to use kqueue. Is this a right direction? It would be nice to hear from someone experienced in this area.

Thanks

like image 641
stas Avatar asked Oct 14 '22 06:10

stas


2 Answers

Boost.Asio is an excellent cross platform, high performance, C++ networking library. On Mac OS X it uses kqueue for the reactor event loop, other platforms use epoll, I/O completion ports, poll, or select. It can scale to thousands of connections without issues. As the name implies, it promotes asynchronous programming by using the proactor design pattern for concurrency without the use of threads.

like image 51
Sam Miller Avatar answered Oct 20 '22 14:10

Sam Miller


If you use libev, you can switch between a variety of compatible asynchronous IO backends (epoll, kqueue, select, etc...) without worrying about implementation details.

http://software.schmorp.de/pkg/libev.html

like image 37
Electric Wig Avatar answered Oct 20 '22 14:10

Electric Wig