title: How does select() monitor sockets?
body: <p>As described in <a href="http://beej.us/guide/bgnet/output/html/singlepage/bgnet.html" rel="nofollow">Beej's Guide to network Programming</a>, select() monitors a set of file descriptors for reading (using <code>recv()</code>), a set of file descriptor for writing (using <code>send()</code>) and the last one, I don't know. When the server socket receives message from client sockets, <code>read_fds</code> set will be modified and <code>select()</code> return from blocking status. It is the same for sending message to client sockets. For example:</p>
  
  <pre><code>for(;;) {
          read_fds = master; // copy it
          if (select(fdmax+1, &amp;read_fds, NULL, NULL, NULL) == -1) {
              perror("select");
              exit(4);
          }
  //the rest is code for processing ready socket
  </code></pre>
  
  <p>I guess the <code>read_fds</code> set will contain the only ready socket descriptor at this point (the others are removed), and the ready socket descriptor is the new connected socket or message sent from connected socket. Is my understanding correct? </p>
  
  <p>It seems the ready socket must be handled one by one. When I tried to run it on gdb to understand the behavior, while the program was processing the ready socket (the code after <code>select()</code> return), I tried to send some message and connect to the server by some new clients. How can it recognize the new clients or newly sent message, even if <code>select()</code> is not called?</p>