CFtpClient::SetChannelMode Method  
 
INT SetChannelMode(
  INT nMode  
);
INT SetChannelMode(
  INT nChannel,  
  INT nMode  
);

The SetChannelMode method changes the security mode for the specified communication channel.

Parameters

nChannel
An integer value which specifies which channel to return information for. If the first version of this method is called, then the data channel mode is modified; otherwise, the channel may be explicitly specified as one of the following values:
Constant Description
FTP_CHANNEL_COMMAND Change information for the command channel. This is the communication channel used to send commands to the server and receive command result and status information from the server.
FTP_CHANNEL_DATA Change information for the data channel. This is the communication channel used to send or receive data during a file transfer.
nMode
An integer value which specifies the new mode for the specified channel. It may be one of the following values:
Constant Description
FTP_CHANNEL_CLEAR Data sent and received on this channel should not be encrypted.
FTP_CHANNEL_SECURE Data sent and received on this channel should be encrypted. Specifying this option requires that a secure connection has already been established with the server.

Return Value

If the method succeeds, the return value is the previous mode for the specified channel. If the method fails, it will return FTP_ERROR. To get extended error information, call FtpGetLastError.

Remarks

The SetChannelMode method is used to change the default mode for the specified channel, and is typically used to control whether or not data is encrypted during a file transfer. If a standard, non-secure connection has been established with the server, an error will be returned if you specify the FTP_CHANNEL_SECURE mode for either channel.

If you have established a secure connection and then specify the FTP_CHANNEL_CLEAR mode for the command channel, the client will send the CCC command to the server to indicate that commands should no longer be encrypted. If the server does not support this command, an error will be returned and the channel mode will remain unchanged. Once the command channel has been changed to clear mode, it cannot be changed back to secure mode. You must disconnect and re-connect to the server if you want to resume sending commands over an encrypted channel.

Changing the mode for the data channel requires that the server support the PROT command. If this command is not supported by the server, the method will fail and the channel mode will remain unchanged.

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: csftpv10.lib

See Also

GetChannelMode