Unix Network Programming, Volume 1: The Sockets Networking API (3rd Edition)
11.4 gethostbyaddr Function
The function gethostbyaddr takes a binary IPv4 address and tries to find the hostname corresponding to that address. This is the reverse of gethostbyname .
This function returns a pointer to the same hostent structure that we described with gethostbyname . The field of interest in this structure is normally h_name , the canonical hostname. The addr argument is not a char *, but is really a pointer to an in_addr structure containing the IPv4 address. len is the size of this structure: 4 for an IPv4 address. The family argument is AF_INET . In terms of the DNS, gethostbyaddr queries a name server for a PTR record in the in-addr.arpa domain. |