summaryrefslogtreecommitdiff
path: root/src/mongo/client/dbclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/client/dbclient.cpp')
-rw-r--r--src/mongo/client/dbclient.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mongo/client/dbclient.cpp b/src/mongo/client/dbclient.cpp
index 4732658795c..efeab45e926 100644
--- a/src/mongo/client/dbclient.cpp
+++ b/src/mongo/client/dbclient.cpp
@@ -845,7 +845,9 @@ Status DBClientConnection::connectSocketOnly(const HostAndPort& serverAddress) {
_failed = true;
// We need to construct a SockAddr so we can resolve the address.
- SockAddr osAddr{serverAddress.host().c_str(), serverAddress.port()};
+ SockAddr osAddr{serverAddress.host().c_str(),
+ serverAddress.port(),
+ static_cast<sa_family_t>(IPv6Enabled() ? AF_UNSPEC : AF_INET)};
if (!osAddr.isValid()) {
return Status(ErrorCodes::InvalidOptions,