The man pages say that the first parameter to select (nfds) should be "an integer one more than the maximum of any file descriptor in any of the sets", but I often see the code that uses FD_SETSIZE like this:
instead of calculated max value like this:Code:ret = select(FD_SETSIZE, ...);
Does this code (with FD_SETSIZE) work, or does it just accidentally work?Code:int nfds = 0; ... nfds = max(nfds, fd1); nfds = max(nfds, fd2); .. ret = select(nfds, ...);
example with max(): http://www.linuxmanpages.com/man2/select_tut.2.php
example with FD_SETSIZE: http://www.delorie.com/gnu/docs/glibc/libc_248.html
Which one is correct?