Searches the host database sequentially from the beginning of the database for a host record with a given name or alias.
#include <netdb.h> struct hostent *gethostbyname (char *name);Routine Variants This socket routine has a variant named __bsd44_gethostbyname. Enabled by defining _SOCKADDR_LEN, this variant implements 4.4BSD-compatible semantics. See Section A.7 for more information.
The gethostbyname routine uses a common static area for its return values. This means that subsequent calls to this routine will overwrite any existing host entry. You must make a copy of the host entry if you wish to save it.
NULL | Indicates an error. |
x | A pointer to an object having the
hostent structure. See <netdb.h> for a description of the hostent
structure.
Depending on the error condition and the socket implementation selected, errno or h_errno might be set to further indicate the error. (See sections A.5 and A.6.) |