Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to increase FD_SETSIZE value

Status
Not open for further replies.

SnipahWUF

Programmer
Jun 30, 2001
4
PH
good day! i have a problem regarding the select( ) function... i opened more than 1024 sockets and used FD_SET( ) macro before using select( ) but it seems that when the maximum file descriptor opened reaches more than 1024 it resets to -1. i think this has something to do with the FD_SETSIZE pre-defined constant in /usr/sys/select.h... can someone help me out how to increase its value? thanks in advance...
 
Max "File descriptors" is limited to 1024 in kernel by default, if you want you can change this by do the following:

i.e. modified /etc/system file and added the following lines:

set rlim_fd_cur=4000
set rlim_fd_max=4000

... reboot, in this case new max descriptors value will be
4000.

Hope this helps,

Carlos Almeida,
 
FD_SETSIZE value has nothing to do with the maximum open file descriptors... FD_SET macro accepts values up to 1024 only... select manipulates file descriptors as bits so we can think that the actual size is only 128 (128 * 8 bits = 1024 bits)... i need to increase this value in order for FD_SET to accept values larger than 1024...
 
Yes you are right, I don't explain myself right i mean select() use FD_SETSIZE, which is normally at least equal to the maximum number of descriptors supported by the system, as you certainly know increase is size by having the program define FD_SETSIZE before the inclusion of any header which includes, doesn't work because the limitation is in the select library call, not in the poll system call. Select is hard-wired at a max of 1024 file descriptors. sorry am not a programmer ... can you use poll ? the poll(2) function is preferred over select function when the number of file descriptors exceeds FD_SETSIZE.

Regards,

Carlos Almeida
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top