Home |
Function gethostbyaddr |
Function gethostbyaddrFunction gethostbyaddr performs a DNS lookup on a given IP address: struct hostent * gethostbyaddr(char * address, int len, int type); Parametersaddress32-bit IP address in network byte order. lenLength of *address. Must be 4. typeType of address. Must be AF_INET. return valueReturns pointer to a hostent structure if successful, otherwise NULL. If an error occurred, call xn_getlasterror and xn_geterror_string to return the error value. Possible values for this function are:
This function performs the reverse of gethostbyname, taking a 32-bit IP address and returning a pointer to a hostent structure, in which the domain name string is contained. The returned pointer points to an entry in an internal host cache. The entries are allocated using a round robin method; therefore, the information returned should be extracted immediately from the entry returned. DNS uses the UDP protocol to retrieve the information from the DNS server. Note that xn_set_server_list must have been called before this function can be used. The hostentext structure is defined as follows: struct hostent { char * h_name; /* official name of host */ char * h_aliases[1]; /* alias list */ WORD h_addrtype; /* host address type */ WORD h_len /* length of address */ char * h_addrlist[3] /* list of addresses */ long l_time_to_live; /* Time to live for entry */ int b_used; /* 1 if entry is used */ char sz_name[100]; struct in_addr ip_addr; char alias[100]; };
|