3

I'm trying to make an asio extension, similar to the boost socket, with implementation both on windows and linux. The extensions will be used to interact with an KNX network using EIBD, for linux. Question is, how to monitor multiple file descriptors. If using select() how to get around the FD_SETSIZE limit?

How does boost handle this in the socket implementation ? From my knowledge, on windows is using IO completion ports.

Sam Miller
  • 23,808
  • 4
  • 67
  • 87
StackedUser
  • 327
  • 2
  • 13

1 Answers1

3

The short answer to my question is using epoll. According to wikipedia, epoll is a scalable I/O event notification mechanism for Linux, first introduced in Linux kernel 2.5.44.

select(2) can monitor up to FD_SETSIZE number of descriptors at a time, typically a small number determined at libc's compile time. Instead, epoll has no such fixed limits, and does not perform any linear scans. Hence it is able to perform better and handle a larger number of events.

For a tutorial on how to use epoll go at banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/

As for Boost, on many platforms, Boost.Asio implements the Proactor design pattern in terms of a Reactor, such as select(kernel 2.4), epoll(kernel 2.6) or kqueue(Mac OS).

On Windows NT, 2000 and XP, Boost.Asio takes advantage of overlapped I/O to provide an efficient implementation of the Proactor design pattern.

More on Boost:

www.boost.org/doc/libs/1_52_0/doc/html/boost_asio/overview/core/async.html

www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/design/implementation.html

StackedUser
  • 327
  • 2
  • 13