PDA

View Full Version : fromName() with localHostName() returns incomplete address list



dv_
31st July 2009, 20:27
Hello,

I am trying to get all local addresses on the host. I issue this call:


QList < QHostAddress > local_addresses = QHostInfo::fromName(QHostInfo::localHostName()).ad dresses();

But the resulting list has only one entry, "127.0.1.1", even though I have a running ethernet connection with its own IP. At the very least the list should have two entries, "127.0.1.1" and the NIC's IP.

Does anybody have an idea what's wrong?

dv_
31st July 2009, 21:03
Found the cause. Debian and Ubuntu associate the hostname with 127.0.0.1 or 127.0.1.1 in the /etc/hosts file. This limits the lookup to these addresses.

Unfortunately, there seems to be no way around this :(