running on? How can I find the full hostname (FQDN) of the

running on? How can I find the full hostname (FQDN) of the


  From Richard Stevens (rstevens@noao.edu):

  Some systems set the hostname to the FQDN and others set it to just
  the unqualified host name.  I know the current BIND FAQ recommends the
  FQDN, but most Solaris systems, for example, tend to use only the
  unqualified host name.

  Regardless, the way around this is to first get the host's name
  (perhaps an FQDN, perhaps unaualified).  Most systems support the
  Posix way to do this using uname(), but older BSD systems only provide
  gethostname().  Call gethostbyname() to find your IP address.  Then
  take the IP address and call gethostbyaddr().  The h_name member of
  the hostent{} should then be your FQDN.

  3.  Writing Client Applications (TCP/SOCK_STREAM)



Home
FAQ