CSocketWrench::GetAddressFamily Method  
 
INT GetAddressFamily(
  LPCTSTR lpszAddress,  
);

Return the address family for the specified IP address.

Parameters

lpszAddress
A pointer to a string which specifies an IP address. This method recognizes the format for both IPv4 and IPv6 format addresses.

Return Value

If the method succeeds, the return value is the address family for the specified IP address and may be one of the values listed below. If the method fails, the return value is INET_ADDRESS_UNKNOWN. To get extended error information, call the GetLastError method.

Constant Description
INET_ADDRESS_IPV4 The address passed to the method is a valid IPv4 address.
INET_ADDRESS_IPV6 The address passed to the method is a valid IPv6 address.

Remarks

The GetAddressFamily method returns the address family associated with the specified IP address string. This can be used to determine if a string specifies a valid IPv4 or IPv6 address that can be passed to other methods such as Connect. Note that this method will not attempt to resolve hostnames, it will only accept IP addresses.

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 lpszAddress 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: Include cswsock10.h
Import Library: cswskv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

IsAddressNull, IsAddressRoutable, IsProtocolAvailable, INTERNET_ADDRESS