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 |
over the socket? Is there a way to have a dynamic buffer? What does one do when one does not know how much information is coming?
How come select says there is data, but read returns zero?
How is a socket created?
Why sockets are used?
What is active unix domain sockets?
How come only the first part of my datagram is getting through?
How many sockets can a cpu have?
What exactly does SO_LINGER do?
What pieces of information make up a socket?
How do Sockets Work?
What's better 6pt or 12pt sockets?
Why do we need socket programming?