|
INT GetHostName( |
|
LPINTERNET_ADDRESS lpAddress, |
|
|
LPTSTR lpszHostName, |
|
|
INT cchHostName |
|
); |
INT GetHostName( |
|
LPINTERNET_ADDRESS lpAddress, |
|
|
CString& strHostName |
|
); |
The GetHostName method 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.
This parameter cannot be NULL. An alternate form of the method accepts a CString argument
which will contain the hostname.
- cchHostName
- The maximum number of characters that can be copied into the
buffer.
Return Value
If the method succeeds, the return value is the length of the
hostname. If the method fails, the return value is INET_ERROR. To get
extended error information, call InetGetLastError.
Remarks
If the method must perform a reverse DNS lookup to resolve the IP
address into a host name, the calling thread will block. This method
requires that the host have a PTR record, otherwise it will fail.
Because many hosts do not have a PTR record, calling this method
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 IsProtocolAvailable
method. If an IPv6 stack is not installed, this method will fail
if the lpAddress parameter specifies an IPv6 address, even if
the address itself is valid.
Requirements
Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cswsock11.h
Import Library: cswskv11.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
GetClientAddress,
GetHostAddress,
GetLocalAddress,
GetLocalName,
IsProtocolAvailable,
INTERNET_ADDRESS
|
|