summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src')
-rwxr-xr-xqpid/cpp/src/qpid/sys/posix/SystemInfo.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp b/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
index 007d0773fc..2b1bbb97df 100755
--- a/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
+++ b/qpid/cpp/src/qpid/sys/posix/SystemInfo.cpp
@@ -34,6 +34,7 @@
#include <fstream>
#include <sstream>
#include <netdb.h>
+#include <string.h>
#ifndef HOST_NAME_MAX
# define HOST_NAME_MAX 256
@@ -125,7 +126,10 @@ namespace {
struct AddrInfo {
struct addrinfo* ptr;
AddrInfo(const std::string& host) : ptr(0) {
- if (::getaddrinfo(host.c_str(), NULL, NULL, &ptr) != 0)
+ ::addrinfo hints;
+ ::memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_UNSPEC; // Allow both IPv4 and IPv6
+ if (::getaddrinfo(host.c_str(), NULL, &hints, &ptr) != 0)
ptr = 0;
}
~AddrInfo() { if (ptr) ::freeaddrinfo(ptr); }