title: How to use the select() function in socket programming?
body: <p>The prototype is:</p>
  
  <pre><code>int select (int nfds,
              fd_set *read-fds,
              fd_set *write-fds,
              fd_set *except-fds,
              struct timeval *timeout);
  </code></pre>
  
  <p>I've been struggling to understand this function for quite some time. My question is, if it checks all the file descriptors from 0 to nfds-1, and will modify the read-fds, write-fds and except-fds when return, why do I need to use FD_SET to add file descriptors to the set at the begining, it will check all the file descriptors anyway, or not?</p>