|
INT EnumClients( |
|
INTERNET_ADDRESS& ipAddress, |
|
|
SOCKET *lpClients, |
|
|
INT nMaxClients |
|
); |
INT EnumClients( |
|
LPCTSTR lpszAddress, |
|
|
SOCKET *lpClients, |
|
|
INT nMaxClients |
|
); |
INT EnumClients( |
|
SOCKET *lpClients, |
|
|
INT nMaxClients |
|
); |
Return a list of active client connections established with the
server.
Parameters
- ipAddress
- A reference to an INTERNET_ADDRESS structure that contains the
IP address that should be matched against the clients connected to
the server. Only those clients that have connected to the server
from this address will be returned in the lpClients array.
- lpszAddress
- A string that specifies the IP address that should be matched
against the clients connected to the server. Only those clients that
have connected to the server from this address will be returned in
the lpClients array.
- lpClients
- Pointer to an array which will contain
the socket handle for each active client session when the method
returns. If this parameter is NULL, then the method will
return the number of active client connections established with
the server.
- nMaxClients
- Maximum number of socket handles to be returned in the lpClients
array. If the lpClients parameter is NULL, this parameter
should have a value of zero.
Return Value
If the method succeeds, the return value is the number of active
client connections to the server. A return value of zero indicates
that there are either no active client sessions, or no clients have
connected using the specified IP address. If the method fails, the return
value is FTP_ERROR. To get extended error information, call the
GetLastError method.
Remarks
If the nMaxClients parameter is less than the number of
active client connections, the method will fail. To
dynamically determine the number of active connections, call the
method with the lpClients parameter with a value of NULL,
and the nMaxClients parameter with a value of zero.
This method will not enumerate clients that have disconnected
from the server, even if the session thread is still active. If the
server is in the process of shutting down, this method will return
zero, indicating no active client sessions, even though there may be
clients that are still in the process of disconnecting from the
server. To determine the actual number of client sessions regardless
of their status, use the GetClientThreads method.
Example
// Populate a listbox with the IP address for each client
pListBox->ResetContent();
INT nClients = pServer->EnumClients();
if (nClients > 0)
{
SOCKET *phClients = new SOCKET[nClients];
nClients = pServer->EnumClients(phClients, nClients);
if (nClients == INET_ERROR)
{
// Unable to obtain list of connected clients
return;
}
for (INT nIndex = 0; nIndex < nClients; nIndex++)
{
CString strAddress;
if (pServer->GetClientAddress(phClients[nIndex], strAddress))
pListBox->AddString(strAddress);
}
// Free the memory allocated for the socket handles
delete phClients;
}
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
See Also
GetClientAddress,
GetClientThreads
|
|