Detecting hostname == localhost?

Thiago Macieira thiagom at
Fri Sep 13 11:48:14 BST 2002

Hash: SHA1

Michael Goffioul wrote:
>I've got a problem that should be fixed before 3.1. I want to detect
>that a given hostname corresponds to localhost. The hostname may be
>in alphabetical or IP address form. Is there an easy way to do that
>using KDE classes?

The known hostnames "localhost", "*" and "" (and "::1" for IPv6) are 
guaranteed to be localhost and you could even hardcode that. However, there 
are other several possibilities of loopback that won't show up unless you 
perform a lookup.

That is the case for "localhost.localdomain" and any other "localhost.*" that 
will show up only by reading /etc/hosts and DNS queries. If that is 
acceptable, I think we could add a member (static?) function isLocalhost() to 
KInetSocketAddress that would return true in case an address is localhost.

However, this would be a new feature...

PS: that would probably be best in KAddressInfo or in the proposed 
KInetAddress class.
- -- 
  Thiago Macieira - UFOT Registry number: 1001
 thiagom at
   ICQ UIN: 1967141  PGP/GPG: 0x6EF45358
     Registered Linux user #65028
Version: GnuPG v1.0.7 (GNU/Linux)


More information about the kde-core-devel mailing list