Network Component  Version 7.19.0
MDK Middleware for IPv4 and IPv6 Networking
Control Interface

Functions to connect to an FTP server. More...

Functions

netStatus netFTPc_Connect (const NET_ADDR *addr, netFTP_Command command)
 Start FTP client file operation session. [thread-safe]. More...
 

Description

Functions to connect to an FTP server.

The FTP client session starts with a connect request using netFTPc_Connect. The FTP client then opens a FTP connection to the server. The FTP command that is to be performed by the FTP server is specified in the connect request parameter. Once the operation has completed, the FTP session ends and the connection closes. If you want to issue another command or transfer files, you need to start a FTP session again.

Function Documentation

◆ netFTPc_Connect()

netStatus netFTPc_Connect ( const NET_ADDR addr,
netFTP_Command  command 
)

Start FTP client file operation session. [thread-safe].

Parameters
[in]addrstructure containing IP address and port of remote FTP server.
[in]commandFTP command to perform.
Returns
status code that indicates the execution status of the function.

The function netFTPc_Connect starts the FTP client. The FTP client then connects to a FTP server specified with the argument addr which points to a buffer containing the IP address and port of the FTP server. If the specified port is 0, the client uses a standard FTP server port 21 to connect to the server.

The argument command specifies a command that is preformed when the FTP client connects to the FTP server. The following commands are supported:

Command Description
netFTP_CommandPUT Puts a local file from local system to FTP server
netFTP_CommandGET Retrieves a file from FTP server to save as a local file
netFTP_CommandAPPEND Appends a local file to an existing file on FTP server
netFTP_CommandDELETE Deletes a file from FTP server
netFTP_CommandLIST Lists files located on FTP server (including detailed information)
netFTP_CommandRENAME Renames a file or directory on FTP server
netFTP_CommandMKDIR Creates a new directory on FTP server
netFTP_CommandRMDIR Deletes an empty directory on FTP server
netFTP_CommandNLIST Lists file names located on FTP server (names only)

Possible netStatus return values:

  • netOK: FTP client started successfully.
  • netInvalidParameter: Invalid FTP server address provided.
  • netWrongState: FTP client is busy.

Code Example

const NET_ADDR4 addr = { NET_ADDR_IP4, 0, 192, 168, 0, 253 };
printf("FTP client started.\n");
}
else {
printf("FTP client is busy.\n");
}