Detecting hostname == localhost?

Michael Goffioul goffioul at imec.be
Fri Sep 13 11:59:52 BST 2002


> 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 "127.0.0.1" (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's not what I meant. Imagine you're working on a computer named
"myhost.mydomain.com" with the given IP "165.89.3.54", I want to check
if strings like:

myhost
myhost.mydomain.com
165.89.3.54

corresponds to localhost, it means the computer you're working on.
My final goal is to replace the given hostname with "localhost" if
the hostname is effectively localhost, and keep the hostname otherwise.
This is to avoid to perform inet connection if the host is local
(this leads to various problems with CUPS server under SuSE default
config, which refuses any connection except those coming from
127.0.0.1).

Michael.

-- 
------------------------------------------------------------------
Michael Goffioul		IMEC-DESICS-MIRA
e-mail: goffioul at imec.be	(Mixed-Signal and RF Applications)
Tel:    +32/16/28-8510		Kapeldreef, 75
Fax:    +32/16/28-1515		3001 HEVERLEE, BELGIUM
------------------------------------------------------------------




More information about the kde-core-devel mailing list