title: Using select() with OpenSSL sockets?
body: <p>I'm attempting to configure my SSL sockets to manage multiple connections using 'select()', however I've been unable to get it working. 
  Currently the connections are being accepted, however they are blocking, therefore the server can only handle reading each request at a time.</p>
  
  <p>Code:</p>
  
  <pre><code>int main(int argc, char **argv)
  {
      int sock;
      SSL_CTX *ctx;
  
      init_openssl(); //Load dependencies
      ctx = create_context(); //Set Protocol
  
      configure_context(ctx); //Set key/cert
  
      sock = create_socket(3000); //Configure and bind listener
  
      fd_set active_fd_set, read_fd_set;
      timeval t;
  
      FD_ZERO(&amp;active_fd_set); //initialise fd active
      FD_SET(sock,&amp;active_fd_set); //includes sock in the fd
  
      while(1)
      {
          int i;
          struct sockaddr_in addr;
          uint len = sizeof(addr);
          SSL *ssl;
  
          read_fd_set=active_fd_set;
  
          if(select(FD_SETSIZE,&amp;read_fd_set,NULL,NULL,NULL)&lt;0)
          {
              std::cout&lt;&lt;"Error at select!"&lt;&lt;std::endl;
          }
  
              for(i=0;i&lt;FD_SETSIZE;i++)
              {
                  if(FD_ISSET(i,&amp;read_fd_set)) //Is fd part of the set
                  {
                      if(i==sock)
                      {
  
                          int client = accept(sock,(struct sockaddr*)&amp;addr,&amp;len);
                          if(client&gt;0){std::cout&lt;&lt;"Client accepted"&lt;&lt;std::endl;}else{std::cout&lt;&lt;"Client failed"&lt;&lt;std::endl;}
                          ssl = SSL_new(ctx); //Create new ssl structure for connection
                          SSL_set_fd(ssl, client);
                          FD_SET(client,&amp;active_fd_set);
                          if(SSL_accept(ssl)&gt;0)
                          {
                              std::cout&lt;&lt;"ACCEPTED"&lt;&lt;std::endl;         
                          }
                      }
                      else
                      {
                          if(SSL_accept(ssl)&gt;0)
                          {
                              std::cout&lt;&lt;"Down here"&lt;&lt;std::endl;
                              close(i);
                              FD_CLR(i,&amp;active_fd_set);
                          }
                      }
                  }
              }
      }
  </code></pre>
  
  <p>Does anyone have any tips on how to get select() working?</p>