How do I find the current machine's full hostname in C (hostname and domain information)?
问题 In a C project (POSIX), how do I get the fully qualified name for the current system? For example, I can get just the hostname of my machine by doing gethostname() from unistd.h. This might give me machine3 in return, but I'm actually looking for machine3.somedomain.com for example. How do I go about getting this information? I do not want to use a call to system() to do this, if possible. 回答1: To get a fully qualified name for a machine, we must first get the local hostname, and then lookup