CInternetServer::FormatAddress Method  
 
INT FormatAddress(
  LPINTERNET_ADDRESS lpAddress,  
  LPTSTR lpszAddress,  
  INT cchAddress  
);
INT FormatAddress(
  LPINTERNET_ADDRESS lpAddress,  
  CString& strAddress  
);

The FormatAddress method converts a numeric IP address to a printable string. The format of the string depends on whether an IPv4 or IPv6 address is specified.

Parameters

lpAddress
A pointer to an INTERNET_ADDRESS structure which specifies the numeric IP address that should be converted to a string.
lpszAddress
A pointer to the buffer that will contain the formatted IP address. This buffer should be at least 46 characters in length. This may also reference a CString object which will contain the formatted address when the method returns.
cchAddress
The maximum number of characters that can be copied into the address buffer.

Return Value

If the method succeeds, the return value is the length of the IP address string. If the method fails, the return value is INET_ERROR, meaning that the IP address could not be converted into a string. Typically this indicates that the pointer to the INTERNET_ADDRESS structure is invalid, or the data does not specify a valid IP address family.

Remarks

The format and length of IPv4 and IPv6 address strings are very different. An IPv4 address string looks like "192.168.0.20", while an IPv6 address string can look something like "fd7c:2f6a:4f4f:ba34::a32". If your application checks for the format of these address strings, it needs to be aware of the differences. You also need to make sure that you're providing enough space to display or store an address to avoid buffer overruns.

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, GetLocalAddress, INTERNET_ADDRESS