Is it possible to listen file descriptor greater than 1024 with select?

I’m a big fan of select() functionality in Linux. Today we see some problems in our software. We’re using a lot of file descriptors in a thread which returned from timerfd_create() function. Sometimes total number of timerfd file descriptors very close or above to 1024. When this happens, we can’t use select() properly on other threads.

I know that maximum number of file descriptors limit which can be listen simultanously is 1024 for select() call. But it is not clear that is there a limit on file descriptor number too? For example can I use select() for two file descriptor, 1025 and 1026?

Although there are some ways to increase this limit (because of you’re using Linux, everything is possible), select() call can only listen 1024 file descriptor at the same time and all of the file descriptor number must be less than 1024

This limit related to how select() works. When you set file descriptor number for example 65 in fd_set structure, you’re setting 65th of bit in a vector which has 1024 bits in total. So, you can’t set file descriptor 1024 and above because there are no corresponding bit in structure.

On the other hand, if number of file descriptors you want to listen in same time is more than 10, it is suggested to use poll() or epoll() mechanism. They don’t have limits like select and unlike select, their performance not changed significiantly when number of listening file descriptor numbers high.