ftpDisconnect (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Firmware version:

2.10 / 1.00.00


This function will disconnect from the FTP server. All references to the connection identification (ID) after this call is illegal.

The connection is closed by quitting the session - thus making sure that the user is correctly logged out.

Any file transfer in progress will be canceled.

 

For each ftpConnect(), there must be a corresponding call to ftpDisconnect(). This is also the case when the connection is closed from the FTP server side (see example below).  

 

Note:

Disconnection with no server communication capability will result in an unclosed session on the server.

 

Input:

ID : INT

The ID returned from ftpConnect.

 

Returns: INT

0

- Success.

- 1

- Failed to close connection.

- 2

- Invalid ID.

- 5

- FTP not open, use ftpOpen to open interface.

 

Declaration:

FUNCTION ftpDisconnect : INT;
VAR_INPUT
   ID     : INT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM example;
VAR
   open  : BOOL;
   host  : STRING := "ftp.domain.com";
   usr   : STRING := "ftpuser";
   pwd   : STRING := "user pwd";
   
   id    : INT;
END_VAR;
 
   gsmPower(power := ON);
   gprsOpen();
 
BEGIN
  open := (ftpOpen() = 0);
  IF open THEN
     id := ftpConnect(host := host, username := usr, password := pwd);
     .
     ...
     ftpDisconnect(id := id);
  END_IF;
  ftpClose();
END;
END_PROGRAM;