| |
| INT WINAPI InetGetAddress(
|
| |
LPCTSTR lpszAddress, |
|
| |
INT nAddressFamily, |
|
| |
LPINTERNET_ADDRESS lpAddress |
|
| );
|
The InetGetAddress function converts an IP address string
to binary format.
Parameters
- lpszAddress
- A pointer to a null terminated string which specifies an IP
address. This function recognizes the format for both IPv4 and IPv6
format addresses.
- nAddressFamily
- An integer which identifies the type of IP address specified by
the lpszAddress parameter. It may be one of the following
values:
| Constant |
Description |
| INET_ADDRESS_UNKNOWN |
Return the IP address for the specified host in either IPv4 or
IPv6 format, depending on the value of the lpszAddress
parameter. |
| INET_ADDRESS_DEFAULT |
Return the IP address for the specified host in the default
format. This is currently the same as specifying INET_ADDRESS_IPV4,
however an application should not depend on this behavior and for
future compatibility should be designed to handle either IPv4 or
IPv6 addresses. |
| INET_ADDRESS_IPV4 |
Specifies that the address should be in IPv4 format. The first
four bytes of the ipNumber array are significant and
contains the IP address. The remaining bytes are not significant
and an application should not depend on them having any particular
value, including zero. If the lpszAddress parameter does not
specify a valid IPv4 address string, this function will fail. |
| INET_ADDRESS_IPV6 |
Specifies that the address should be in IPv6 format. All bytes
in the ipNumber array are significant. If the
lpszAddress parameter does not specify a valid IPv6 address
string, this function will fail. |
- lpAddress
- A pointer to an INTERNET_ADDRESS structure that will
contain the IP address.
Return Value
If the function succeeds, the return value is zero. If the
function fails, the return value is INET_ERROR. To get extended
error information, call InetGetLastError.
Remarks
If the nAddressFamily parameter is specified as
INET_ADDRESS_UNKNOWN, the application must be prepared to handle
IPv6 addresses because it is possible that an IPv6 address string
has been specified. For legacy applications that only recognize
IPv4 addresses, the nAddressFamily member should always be
specified as INET_ADDRESS_IPV4 to ensure that only IPv4 addresses
are returned and any attempt to specify an IPv6 address string
would result in an error.
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 lpszAddress
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
InetFormatAddress, InetGetLocalAddress, InetGetPeerAddress, InetIsProtocolAvailable,
INTERNET_ADDRESS
|
|