#include <iostream>
#include <mongo/client/dbclient.h>
using namespace mongo;
int main() {
try {
DBClientConnection c;
BSONObj o;
c.connect("mongohostname:12345");
c.simpleCommand( "admin", &o, "whatsmyuri" );
cout << "connected ok on " << o.getField( "you" ) << endl;
} catch( DBException &e ) {
cout << "caught " << e.what() << endl;
}
return 0;
}
where instead of DBClientConnection c, you'd use myScopedDbConnection.conn(). This will report the connection's URI, which you can then correlate to the mongod logs.