tfFtpdUserStart
Table of Contents >> Application Reference >> FTPD API
| The content on this page has been deprecated. | |
| For the new content, please see tfNgFtpdUserStart(). |
| #include <trsocket.h> |
| int tfFtpdUserStart | ( |
| int fileFlags, | |
| int maxConnections, | |
| int maxBackLog, | |
| int idleTimeout, | |
| int blockingState | |
| ); |
Contents
Function Description
This function opens an FTP server socket and starts listening for incoming connections. tfFtpdUserStart() can be either blocking or non-blocking as specified by its blockingState parameter.
Blocking Mode
In blocking mode, tfFtpdUserStart() should be called from a task. tfFtpdUserStart() will not return unless an error occurs. It will block and wait for incoming connections, and execute the FTP server code in the context of the calling task. Choose blocking mode if you are using an RTOS/Kernel.
Non-Blocking Mode
In non-blocking mode, tfFtpdUserStart() will return immediately after listening for incoming connections. It is the user's responsibility to then call tfFtpdUserExecute() periodically to execute the FTP server code. Choose non-blocking mode if you do not have an RTOS/Kernel.
Parameters
- 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, 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.
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. |
Returns
- TM_ENOERROR
- Success.
- TM_EINVAL
- 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).
- TM_EALREADY
- tfFtpdUserStart() has already been called.
- TM_EMFILE
- No more sockets available to open the FTPD listening socket.
- TM_ENOBUFS
- Insufficient memory to complete the operation.
- TM_EADDRINUSE
- The FTP server port is already in use.
- TM_ENOMEM
- Could not obtain a counting semaphore to be used for blocking the FTP server (blocking mode only).