GetHostByAddr: Populate the supplied string with the servername (hostname) at the supplied IP address. Return the DNS return code.

Return TypeFunction nameArguments
hzEcodeGetHostByAddr(hzString&,const char*,)

Declared in file: hzDNS.h
Defined in file : hzDNS.cpp

Function Logic:

0:START 1:x pHost items 2:unknown 3:Host 4:Return E_OK 5:h_errno 6:HOST_NOT_FOUND 7:Return E_DNS_NOHOST 8:NO_DATA 9:Return E_DNS_NODATA 10:NO_RECOVERY 11:Return E_DNS_FAILED 12:TRY_AGAIN 13:Return E_DNS_RETRY 14:Return E_DNS_FAILED

Function body:

hzEcode GetHostByAddr (hzString& Host)const char* cpIPAddr, 
{
   //  Category: Internet
   //  
   //  GetHostByAddr: Populate the supplied string with the servername (hostname) at the supplied IP address. Return the DNS
   //  return code.
   //  
   //  Arguments: 1) Host  The Hostname (at the supplied IP address)
   //     2) cpIPAddr The IP address
   //  
   //  Returns: E_DNS_NOHOST If the host is unknown.
   //     E_DNS_NODATA If the name is valid but does not have an IP address.
   //     E_DNS_FAILED If a non-recoverable name server error occurred.
   //     E_DNS_RETRY  If a temporary error occurred on an authoritative name server.
   //     E_OK   If the hostname is found by the DNS
   _hzfunc(__func__) ;
   HOSTENT*    pHost ;     //  Pointer to host from gethostbyaddr()
   in_addr     x ;         //  Internet address translated by inet_addr()
   x.s_addr = inet_addr(cpIPAddr) ;
   //  Unix only: win xlate: pHost = gethostbyaddr(cpIPAddr, 4, AF_INET) ;
   pHost = gethostbyaddr(&x, 4,AF_INET) ;
   Host.Clear() ;
   if (pHost)
   {
       Host = pHost->h_name ;
       return E_OK ;
   }
   switch (h_errno)
   {
   case HOST_NOT_FOUND:    return E_DNS_NOHOST ;   //  The host is unknown.
   case NO_DATA:           return E_DNS_NODATA ;   //  The name is valid but does not have an IP address.
   case NO_RECOVERY:       return E_DNS_FAILED ;   //  A non-recoverable name server error occurred.
   case TRY_AGAIN:         return E_DNS_RETRY ;    //  A temporary error occurred on an authoritative name server.
   }
   return E_DNS_FAILED ;
}