InetGetHostName Function  
 
INT WINAPI InetGetHostName(
  LPINTERNET_ADDRESS lpAddress,  
  LPTSTR lpszHostName,  
  INT cchHostName  
);

The InetGetHostName function performs a reverse lookup, returning the host name associated with a given IP address.

Parameters

lpAddress
A pointer to an INTERNET_ADDRESS structure which specifies the IP address that should be resolved into a host name.
lpszHostName
A pointer to the buffer that will contain the host name. It is recommended that this buffer be at least 256 characters in length to accommodate the longest possible fully qualified domain name.
cchHostName
The maximum number of characters that can be copied into the buffer.

Return Value

If the function succeeds, the return value is the length of the hostname. If the function fails, the return value is INET_ERROR. To get extended error information, call InetGetLastError.

Remarks

If the function must perform a reverse DNS lookup to resolve the IP address into a host name, the calling thread will block. This function requires that the host have a PTR record, otherwise it will fail. Because many hosts do not have a PTR record, calling this function frequently may have a negative impact on the overall performance of the application.

To determine if the local system has an IPv6 TCP/IP stack installed and configured on the local system, use the InetIsProtocolAvailable function. If an IPv6 stack is not installed, this function will fail if the lpAddress parameter specifies an IPv6 address, even if the address itself is valid.

Requirements

Client: Requires Windows 7, Windows Vista or Windows XP.
Server: Requires Windows Server 2008 or Windows Server 2003.
Header: Include cswsock7.h.
Library: Use cswskav7.lib.
Unicode: Implemented as Unicode and ANSI versions.

See Also

InetGetHostAddress, InetGetLocalAddress, InetGetLocalName, InetGetPeerAddress, InetIsProtocolAvailable, INTERNET_ADDRESS