Searches the hosts database that is referenced by the TCPIP$HOST logical name for a host record with a given IPv4 address. If the host record is not found there, the function may also invoke the BIND resolver to query the appropriate name server. The $QIO equivalent is the IO$_ACPCONTROL function with the INETACP_FUNC$C_GETHOSTBYADDR subfunction code. Format #include <netdb.h> struct hostent *gethostbyaddr ( const void *addr, size_t len, int type );
1 – Arguments
addr A pointer to a series of bytes in network order specifying the address of the host sought. len The number of bytes in the address pointed to by the addr argument. type The type of address format being sought (AF_INET).
2 – Description
This function finds the first host record with the specified address in the hosts database or using DNS/BIND. The gethostbyaddr() function uses a common static area for its return values. This means that subsequent calls to this function overwrite previously returned host entries. You must make a copy of the host entry if you want to save it.
3 – Return Values
x A pointer to an object having the hostent structure. NULL Indicates an error; errno is set to one of the following values.
4 – Errors
ENETDOWN TCP/IP Services was not started. HOST_NOT_FOUND Host is unknown. NO_DATA The server recognized the request and the name, but no address is available for the name. Another type of name server request may be successful. NO_RECOVERY An unexpected server failure occurred. This is a nonrecoverable error. TRY_AGAIN A transient error occurred; for example, the server did not respond. A retry may be successful.