make the select implementation work with more than 1024 filedescriptors

fd_set is limited in size so a workaround is necessary when the number
of filedescriptors is bigger than its number of bits