summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rwxr-xr-xcpp/src/qpid/sys/posix/SystemInfo.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/cpp/src/qpid/sys/posix/SystemInfo.cpp b/cpp/src/qpid/sys/posix/SystemInfo.cpp
index c054931a96..9bbd023e29 100755
--- a/cpp/src/qpid/sys/posix/SystemInfo.cpp
+++ b/cpp/src/qpid/sys/posix/SystemInfo.cpp
@@ -53,11 +53,10 @@ bool SystemInfo::getLocalHostname (TcpAddress &address) {
return true;
}
+static const string LOCALHOST("127.0.0.1");
+
void SystemInfo::getLocalIpAddresses (uint16_t port,
std::vector<Address> &addrList) {
-
- static const string LOCALHOST("127.0.0.1");
-
int s = socket (PF_INET, SOCK_STREAM, 0);
for (int i=1;;i++) {
struct ifreq ifr;
@@ -72,6 +71,9 @@ void SystemInfo::getLocalIpAddresses (uint16_t port,
if (addr != LOCALHOST)
addrList.push_back(TcpAddress(addr, port));
}
+ if (addrList.empty()) {
+ addrList.push_back(TcpAddress(LOCALHOST, port));
+ }
close (s);
}