|
INT GetAddress( |
|
UINT nClientId, |
|
|
LPTSTR lpszAddress, |
|
|
INT nMaxLength |
|
); |
INT GetAddress( |
|
UINT nClientId, |
|
|
CString& strAddress |
|
); |
Return the IP address of the server.
Parameters
- nClientId
- An unsigned integer which uniquely identifies the client
session. This value may be zero.
- lpszAddress
- A null-terminated string buffer that will contain the server IP
address, terminated with a null character. To accommodate both IPv4
and IPv6 addresses, this buffer should be at least 46 characters in
length. This parameter cannot be NULL. An alternate version of this
method accepts a CString
object if it is available.
- nMaxLength
- An integer value that specifies the maximum number of characters
can be copied into the string buffer, including the terminating null
character. This value must be greater than zero. If the buffer size
is too small, the method will fail.
Return Value
If the method succeeds, the return value is the number of
characters copied into the string buffer, not including the
terminating null character. If either the client ID is invalid, or
the buffer is not large enough to store the complete address, the
method will return a value of zero.
Remarks
This method will return the IP address assigned to the specified
server as a printable string. If the nClientId parameter has a
value of zero, this method will return the IP address assigned to
the local system. If the HTTP_SERVER_NATROUTER option was specified
when the server was started, this method will return the external IP
address assigned to the system. If the nClientId parameter
specifies a valid client session, this method will return the IP
address that the client used to establish the connection with the
server. To determine the IP address assigned to the client, use the
GetClientAddress method.
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: cstools11.h
Import Library: cshtsv11.lib
Unicode: Implemented as Unicode and ANSI versions
See Also
GetClientAddress,
GetName
|
|