Jump to: navigation, search

Table of Contents >> Application Reference >> FTPD API

#include <trsocket.h>

int tfNgFtpdUserStart (
int fileFlags,
int maxConnections,
int maxBackLog,
int idleTimeout,
int blockingState,
unsigned long flags

Function Description

This function replaces tfFtpdUserStart() and opens an FTP server socket and starts listening for incoming connections. tfNgFtpdUserStart() can be either blocking or non-blocking as specified by its blockingState parameter.


  • fileFlags
    Indicates which FTP file commands are supported by the file system. It is the result of OR'ing together the flags (described below) corresponding to the FTP commands supported by the file system.
  • maxConnections
    Maximum number of concurrent accepted incoming FTP connections allowed. If zero, then the FTP server will accept as many connections as there are available sockets.
  • maxBackLog
    Maximum number of concurrent pending (before being accepted) incoming FTP connections allowed.
  • idleTimeout
    Amount of time in seconds that a connection can sit idle before the server closes that connection. If set to zero, the default idle timeout value (300 seconds (5 minutes)) is used.
  • blockingState
    One of the following:
  • TM_BLOCKING_ON for blocking mode.
  • TM_BLOCKING_OFF for non-blocking mode.
  • flags
    You can OR one or more of the following flags:
When the stack is compiled to support both IPv4 and IPv6, the user may restrict the FTP server to only using IPv4 by setting this flag.
To prevent the FTP bounce attack, the FTP server (starting with release will, by default, return an error when receiving an FTP port command whose IP address does not match the IP address on the control connection. To change the behavior of the FTP server, so that it behaves as in releases prior to release, i.e. allow a PORT command with an IP address different from the control connection peer IP address, set this flag

File System Flags

Flag Description
TM_FS_CWD_FLAG Supports change working directory.
TM_FS_SMNT_FLAG Supports structure mount.
TM_FS_RETR_FLAG Supports reading from a file.
TM_FS_STOR_FLAG Supports writing to a file.
TM_FS_STORU_FLAG Supports writing to a file, making up a new name, if the file name already exists.
TM_FS_APPEND_FLAG Supports append to a file.
TM_FS_RENAME_FLAG Supports renaming of file name.
TM_FS_DELETE_FLAG Supports deletion of file.
TM_FS_RMD_FLAG Supports removing directory.
TM_FS_MKD_FLAG Supports making directory.
TM_FS_PWD_FLAG Supports retrieving the current working directory.
TM_FS_LIST_FLAG Supports long listing of directory (file names, volume, and directories).
TM_FS_NLST_FLAG Supports short listing of directory (file names only).
TM_FS_CR_LF_FLAG The file system end of line is CR, LF.
TM_FS_RECORD_FLAG The file system supports record structures. If this flag is set the FTP server will interpret the FTP record bytes if the FTP client transfers data with record structure.
TM_FS_ALLCMND_MASK OR'ing of all above command flags.


    One of the following:
  • flags is something besides what is listed above.
  • maxConnections is either negative, or it either exceeds or equals the current number of available FTP connections (see note below).
  • maxBackLog is either negative, null, or it exceeds the current number of available FTP connections (see note below).
    tfNgFtpdUserStart() has already been called.
    No more sockets available to open the FTPD listening socket.
    Insufficient memory to complete the operation.
    The FTP server port is already in use.
    Could not obtain a counting semaphore to be used for blocking the FTP server (blocking mode only).

Note Note: * The number of available connections is computed by figuring out the number of unused sockets in the system, subtracting one for the FTP listening socket, one for a transient listening socket for a passive data connection, one to send a 421 error string, and a RESET when we reach the maximum number of available connections, and dividing by 2 to allow for 2 sockets (one control socket, and one data socket) per connection: (numberUnusedSockets - 3 ) / 2

Table of Contents >> Application Reference >> FTPD API