How can I find the full hostname (FQDN) of the system I am running on?
Answer / chaitanya
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.
| Is This Answer Correct ? | 1 Yes | 0 No |
What is a socket api?
Is there any advantage to handling the signal, rather than just ignoring it and checking for the EPIPE error? Are there any useful parameters passed to the signal catching function?
What is the purpose of socket?
What is the function of socket?
What is difference between socket () and serversocket () class?
What is LILO?
How to find other end of unix socket connection?
How can I read ICMP errors from connected UDP sockets?
How does a socket work?
Why do I keep getting EINTR from the socket calls?
Is socket a hardware or software?
What is the difference between close() and shutdown()?