title: MongoDB socket exception after query that returns no results
body: <ul>
  <li><p>Now, in the simplified snippet below, if my query returns results,
  everything is ok. </p></li>
  <li><p>If query returns no results, then everything still goes as expected,
  an Exception is thrown and caught. </p></li>
  <li><p>After this query, if I try to execute yet another query, the
  statement <code>dbConn-&gt;query(collection, queryObj)</code> throws a <code>mongo::SocketException</code>. And the message printed is:</p>
  
  <p><code>socket exception [SEND_ERROR] for 127.0.0.1:27017 // 9001 socket exception [2] server [127.0.0.1:27017]</code></p></li>
  <li><p>From this one on, the following queries all throw the same exception, with a different message:
  <code>socket exception [FAILED_STATE] for localhost:27017 // 9001 socket exception [5] server [localhost:27017]</code></p></li>
  <li><p>I have also printed out error code strings, both of them are "Unknown error"s.</p></li>
  <li><p>If I restart the process, it resets, therefore I'm assuming the connection is somehow damaged. No one else is accessing the shared ptr at the moment. mongo daemon runs fine and there is nothing unusual in mongodb log.</p></li>
  <li><p>My big question is: Why does happen?</p></li>
  </ul>
  
  <p>The snippet:</p>
  
  <pre><code>try
  {
      // Some initialzation here..
      // dbConn is a boost::shared_ptr&lt;mongo::DBClientConnection&gt;
  
      std::auto_ptr&lt;mongo::DBClientCursor&gt; cursor = dbConn-&gt;query(collection, queryObj);
      if (!cursor-&gt;more())
      {
          throw Exception();
      }
  }
  catch(const Exception&amp;)
  {
  
  }
  catch(const mongo::SocketException&amp; e)
  {
      std::cout &lt;&lt; ex.what() &lt;&lt; "//" &lt;&lt; ex.toString() &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>MongoDB C++ driver version is 2.3.2.</p>