FtpSetIdleTimeout Function  
 
INT WINAPI FtpSetIdleTimeout(
  HCLIENT hClient,  
  INT nIdleTime  
);

The FtpSetIdleTimeout function sets the server-side idle timeout period for the control connection.

Parameters

hClient
Handle to the client session.
nIdleTime
The number of seconds until the control session is considered inactive. A value of zero specifies the default idle timeout period of 300 seconds (5 minutes) will be used. If the value is less than 30 seconds or greater than 7200 seconds, it will be automatically adjusted to fit within the valid range.

Return Value

If the function succeeds, the return value is the previous idle timeout period. If the function fails, the return value is FTP_ERROR. To get extended error information, call FtpGetLastError.

Remarks

The FtpSetIdleTimeout function changes the idle timeout period for the control connection, which can be useful in scenarios where a file transfer session is expected to remain idle for extended periods between commands. For example, when transferring large batches of files or performing periodic synchronization, the server may automatically close the connection if no activity is detected within its default timeout period. Increasing the idle timeout helps prevent unexpected disconnects during these idle periods, reducing the need to repeatedly reconnect and re-authenticate. Conversely, reducing the timeout can be used to enforce shorter sessions in security-sensitive environments.

The SITE IDLE command is a non-standard extension to the FTP protocol that allows a client to query or set the server's idle timeout period for the current session. When supported, it enables the client to request how long the server should wait during periods of inactivity before automatically closing the connection. This setting does not affect the duration of data transfers, only how long the control session is kept open when idle.

Because SITE IDLE is not part of the official FTP specification, support for it varies between servers. If the command is not supported, the function will fail but the session will remain connected using the server's default timeout settings. The function will also return an error if a negative timeout value is specified or if the session is using SFTP, which does not support this operation.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: csftpv12.lib

See Also