title: MongoDB workaround for blocking connection or change timeout for connecting. [C++]
body: <p>Is there a way to change the C++ connection timeout? as per this bug report, it seems not. But it says there is a simple workaround, and I'm not sure what.</p>
  
  <p><a href="https://jira.mongodb.org/browse/SERVER-3983" rel="nofollow">https://jira.mongodb.org/browse/SERVER-3983</a></p>
  
  <p>I have autoreconnect on, and when the connection to the server goes down, it seems like the whole application hangs for 5s while it tries to reconnect. What would be the solution? is there a way to do a non-blocking <code>connect</code> call? I do check if the connection is open,</p>
  
  <pre><code>if(conn-&gt;isStillConnected ()){
          try {
              conn-&gt;insert(ns, obj, flags);
              std::string e = conn-&gt;getLastError();
              if( !e.empty() ) { 
                  std::string err = "Insert failed: ";
                  ...
                  return false;
              }
          }
          catch (mongo::DBException&amp; e) {
              ...
              return false;
          }
      }
      else {
          return false;
      }
  </code></pre>
  
  <p>As you can see, I want to just skip updates/inserts if the connection is bad without blocking the main thread. </p>
  
  <p>I can implement threading, but the whole software package I'm working with doesn't seem to use them, and I would like to avoid doing that if possible.</p>