I want to increase FD_SETSIZE macro value for my system.
Is there any way to increase FD_SETSIZE so select will not fail
I want to increase FD_SETSIZE macro value for my system. Is there any way
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Per the standards, there is no way to increase
FD_SETSIZE. Some programs and libraries (libevent comes to mind) try to work around this by allocating additional space for thefd_setobject and passing values larger thanFD_SETSIZEto theFD_*macros, but this is a very bad idea since robust implementations may perform bounds-checking on the argument and abort if it’s out of range.I have an alternate solution that should always work (even though it’s not required to by the standards). Instead of a single
fd_setobject, allocate an array of them large enough to hold the max fd you’ll need, then useFD_SET(fd%FD_SETSIZE, &fds_array[fd/FD_SETSIZE])etc. to access the set.