Re: getting fqdn from gethostname on a hamm box
Martin Schulze wrote (Wed, 26 Aug 1998 02:12:58 +0200 ):
|>> Martin Schulze wrote (Wed, 26 Aug 1998 01:04:36 +0200 ):
|>> |>If you want to write portable programs then you use gethostname() to
|>> |>determine the hostname, check for a '.' and if it's not included you
|>> |>use gethostbyname() to get the fqdn. For an example, take a look at
|>> |>the syslogd source.
|>
|>This doesn't work on Solaris? Why, you should tell us why it fails.
|>
ok, i've found one case where neither gethostname() nor the method
Joey descibed worked in getting the fqdn. on that particular machine,
i found that the h_name field still had the simple name, but that
h_aliases[0] contained the fqdn. so, it's in there somewhere, it's
just not always in the h_name field of the struct hostent.
now my question is this: how does one tell how many aliases are in
the h_aliases vector? do i just keep examining the elements of the
vector until one of them is null?
thanks everyone...
-alan
Reply to: