views:

27

answers:

1

I have just been reading the section on the poll() function in "Advanced Unix Programming" second edition by Marc Rochkind. In this section, the author mentions that poll() is not supported under Darwin 6.6 and I have seen other items on the internet that suggests that poll() is emulated on OSX using the select() system call. I am wanting to use poll() for a class on which I am working specifically because it may be servicing a large number of sockets and I am concerned about exceeding the limit of the number of file handles that select() can use. If the statements that I have read are true, is there a suitable alternative to select() or is there a way to overcome the FD_SETSIZE limitation?

+2  A: 

poll(2) was introduced as a layer over select(2) in 10.3, and got a native implementation in 10.4.

Most modern BSD-based systems have implemented poll() over the last few years. If you get actual benefits from poll() (vs. select()), I'd recommend using it. Even on systems which still emulate poll() via select(), at worst your performance will be that of select() with a marginal penalty.

If you're in a situation where the scalability of select() would never be acceptable, BSD-derived systems tend to have a very tuned kqueue(2).

Mieko