[Spread-users] usage of gethostname

Göran Hasse gorhas at gmail.com
Sat Feb 4 01:07:20 EST 2012

I gathered that there is a new release in pipeline and want to discuss a

In configuration.c there is a usage of gethostname

 /* Match my IP address to entry in configuration file */
    if( my_name == NULL ){
        host_ptr = gethostbyname(machine_name);

But I will argue that the hostname has nothing to do with *interface names*

Line of reasoning... (There is so many names around in a Unix system!).

First we have the KERNELNAME!

This is the current compiled kernel running in the system.
We get this with uname -a and typicaly gives us key information on the
Linux fs487 2.6.38-13-generic #53-Ubuntu SMP Mon Nov 28 19:33:45 UTC 2011
x86_64 x86_64 x86_64 GNU/Linux

Then whe have INTERFACE NAMES!

A unix system could have a lot of interfaces

We give them IP-numbers

ifconfig eth0 inet ...
ifconfig eth0:1 inet ...
ifconfig eth1 inet ....

And so on! To handle this long list of interface id we make a database
(DNS) or for convinience
make a small database in /etc/hosts. In this database we holds small
aliases for the interfaces.
/etc/hosts    road.to.perdition.org  perdition    road.to.paradise.org  paradise

Then we have the HOSTNAME

This is the name of the *hardware* on which we are running. This name
should NOT! be used in any way in association with the interface names. I
know that this is often so - but it should

So I argue that the function *getaddrinfo* should be used instad. Not that
the manpage
of this function also mix the terminology "node" and "host" in a confusing

Cordially yours,
Göran Hasse

gorhas at gmail.com
Göran Hasse
Boo 229
Mob: 070-5530148
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.spread.org/pipermail/spread-users/attachments/20120204/f90b9d5b/attachment.html 

More information about the Spread-users mailing list