CFtpServer::OnConnect Method  
 
virtual void OnConnect(
  UINT nClientId,  
  LPCTSTR lpszAddress  
);

A virtual method that is invoked after the client has connected to the server.

Parameters

nClientId
An unsigned integer which uniquely identifies the client session.
lpszAddress
A pointer to a string that specifies the IP address of the client. This address may either be in IPv4 or IPv6 format, depending on how the server was configured and the address the client used to establish the connection.

Return Value

None.

Remarks

The OnConnect event handler is invoked after the client has connected to the server. To implement an event handler, the application should create a class derived from the CFtpServer class, and then override this method.

This event only occurs after the server has checked the active client limits and the TLS handshake has been performed, if security has been enabled. If the server has been suspended, or the limit on the maximum number of client sessions has been exceeded, the server will terminate the client session prior to this event handler being invoked.

If this event handler is not implemented, the server will perform the default action of accepting the connection and sending a standard greeting to the client. If you want your application to send a custom greeting to the client when it connects, call the SendResponse method, specifying a result code of 220 and a message of your choice.

To reject a connection, call the SendResponse method to send an error response to the client. Typically the result code value would be 421 to indicate that the server will not accept the connection. Next, call the DisconnectClient method to terminate the client session.

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csftsv10.lib
Unicode: Implemented as Unicode and ANSI versions.

See Also

DisconnectClient, OnDisconnect, SendResponse