CHttpServer::GetClientVirtualHost Method  
 
INT GetClientVirtualHost(
  UINT nClientId,  
  LPTSTR lpszHostName,  
  INT nMaxLength  
);
INT GetClientVirtualHost(
  UINT nClientId,  
  CString& strHostName  
);

Return the name of the virtual host the client used to establish the connection.

Parameters

nClientId
An unsigned integer which uniquely identifies the client session.
lpszHostName
A null-terminated string buffer that will contain the virtual host name. The string buffer will be null-terminated and must be large enough to store the complete hostname. If this parameter is NULL, the method will only return the length of the current command in characters, not including the terminating null character. 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 that can be copied into the string buffer, including the terminating null character. If the maximum length specified is smaller than the actual length of the parameter, this method will fail. If the lpszHostName parameter is NULL, this value should be zero.

Return Value

An integer value which specifies the number of characters copied into the buffer, not including the terminating null character. If the method fails, the return value will be zero and the GetLastError method can be used to retrieve the last error code.

Remarks

The GetClientVirtualHost method is used to obtain the hostname that the client used to establish a connection with the server. This method is typically used within an event handler to determine the hostname associated with the request made by the client. It should not be called inside an OnConnect event handler because the virtual host has not been selected at that point. If the virtual hostname is not available at the time this method is called, the method will return zero and the last error code will be set to ST_ERROR_VIRTUAL_HOST_NOT_FOUND.

The GetClientVirtualHostId method can be used to obtain the virtual host ID associated with the hostname.

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

GetClientVirtualHostId, GetCommandUrl, GetVirtualHostName