Gets network host entry by address.
Standard C Library (libc.a) (libbind) (libnis) (liblocal)
#include <netdb.h>
struct hostent *gethostbyaddr ( Address, Length, Type)
char *Address;
int Length, Type;
Attention: Do not use the gethostbyaddr subroutine in a multithreaded environment.
The gethostbyaddr subroutine retrieves information about a host using the host address as a search key. Unless specified, the gethostbyaddr subroutine uses the default name services ordering, that is, it will query DNS/BIND, NIS, then the local /etc/hosts file.
When using DNS/BIND name service resolution, if the file /etc/resolv.conf exists, the gethostbyaddr subroutine queries the domain name server. .The gethostbyaddr subroutine recognizes domain name servers as described in RFC 883.
When using NIS for name resolution, if the getdomainname subroutine is successful and yp_bind indicates NIS is running, then the gethostbyaddr subroutine queries NIS.
The gethostbyaddr subroutine also searches the local /etc/hosts file when indicated to do so.
The gethostbyaddr returns a pointer to a hostent structure, which contains information obtained from one of the name resolutions services. The hostent structure is defined in the netdb.h file.
The environment variable, NSORDER can be set to override the default name services ordering and the order specified in the /etc/netsvc.conf file.
The gethostbyaddr subroutine returns a pointer to a hostent structure upon success.
Note: The return value points to static data that is overwritten by subsequent calls so it must be copied if it is to be saved.
If an error occurs or if the end of the file is reached, the gethostbyaddr subroutine returns a NULL pointer and sets h_errno to indicate the error.
The gethostbyaddr
subroutine is unsuccessful if any of the following errors occur:
The gethostbyaddr subroutine is part of Base Operating System (BOS) Runtime.
/etc/hosts | |
Contains the host-name database. | |
/etc/resolv.conf | |
Contains the name server and domain name information. | |
/etc/netsvc.conf | Contains the name of the services ording. |
/usr/include/netdb.h | Contains the network database structure. |
The endhostent subroutine, gethostbyname subroutine, sethostent subroutine, gethostent subroutine, inet_addr subroutine.
Sockets Overview, and Network Address Translation in AIX 5L Version 5.1 Communications Programming Concepts.