static OutMessage query(
     Mongo m,
     int options,
     String ns,
     int numToSkip,
     int batchSize,
     DBObject query,
     DBObject fields) {
   OutMessage out = new OutMessage(m, 2004);
   out._appendQuery(options, ns, numToSkip, batchSize, query, fields);
   return out;
 }
  private synchronized Response go(
      OutMessage msg,
      DBCollection coll,
      boolean forceReponse,
      ReadPreference readPref,
      DBDecoder decoder)
      throws IOException {

    if (_processingResponse) {
      if (coll == null) {
        // this could be a pipeline and should be safe
      } else {
        // this could cause issues since we're reading data off the wire
        throw new IllegalStateException(
            "DBPort.go called and expecting a response while processing another response");
      }
    }

    _calls++;

    if (_socket == null) _open();

    if (_out == null) throw new IllegalStateException("_out shouldn't be null");

    try {
      msg.prepare();
      msg.pipe(_out);

      if (_pool != null) _pool._everWorked = true;

      if (coll == null && !forceReponse) return null;

      _processingResponse = true;
      return new Response(_sa, coll, _in, (decoder == null ? _decoder : decoder));
    } catch (IOException ioe) {
      close();
      throw ioe;
    } finally {
      _processingResponse = false;
    }
  }
 private synchronized Response findOne(String ns, DBObject q) throws IOException {
   OutMessage msg = OutMessage.query(null, 0, ns, 0, -1, q, null);
   Response res = go(msg, null, true, null, null);
   return res;
 }
 private synchronized Response findOne(DB db, String coll, DBObject q) throws IOException {
   OutMessage msg = OutMessage.query(db._mongo, 0, db.getName() + "." + coll, 0, -1, q, null);
   Response res = go(msg, db.getCollection(coll), null);
   return res;
 }