I am trying to connect to a local MongoDB Server(3.0.7) using MongoDB C++ Legacy Driver 1.0.6 on Windows inside Visual Studio 2015.
The program is as simple as following:
// MongoTest.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <WinSock2.h>
#include "mongo\client\dbclient.h"
int main()
{
mongo::DBClientConnection c;
c.connect("127.0.0.1");
mongo::client::initialize();
try {
std::cout << "connected ok" << std::endl;
}
catch (const mongo::DBException &e) {
std::cout << "caught " << e.what() << std::endl;
}
return 0;
}But I keep getting unhandled exception thrown from c.connect("localhost");, with errmsg: "couldn't initialize connection to host 127.0.0.1, address is invalid". But I've checked that the server is running correctly with connecting to it with mongo 127.0.0.1:27017
Why is that? How could I fix it?
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/c1513acc-43e3-418e-9c5a-b49d981cbd90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.