On this page:
4.1 Functions
4.2 FTP Unit
4.3 FTP Signature

4 FTP: Client Downloading

The net/ftp library provides utilities for FTP client operations.
The library was written by Micah Flatt.

4.1 Functions

(ftp-connection? v)  boolean?
  v : any/c
Returns #t if v represents an FTP connection as returned by ftp-establish-connection, #f otherwise.

(ftp-establish-connection server    
  passwd)  ftp-connection?
  server : string?
  port-no : (integer-in 0 65535)
  user : string?
  passwd : string?
Establishes an FTP connection with the given server using the supplied username and password. The port-np argument usually should be 21.

(ftp-close-connection ftp-conn)  void?
  ftp-conn : ftp-connection?
Closes an FTP connection.

(ftp-cd ftp-conn new-dir)  void?
  ftp-conn : ftp-connection?
  new-dir : string?
Changes the current directory on the FTP server to new-dir. The new-dir argument is not interpreted at all, but simply passed on to the server; it must not contain a newline.

(ftp-directory-list ftp-conn [path])
(listof (list/c (one-of/c "-" "d" "l")
  ftp-conn : ftp-connection?
  path : (or/c false/c string?) = #f
Returns a list of files and directories in the current directory of the server, assuming that the server provides directory information in the quasi-standard Unix format. If a path argument is given, use it instead of the current directory.

Each file or directory is represented by a list of three or four strings. The first string is either "-", "d", or "l", depending on whether the items is a file, directory, or link, respectively. The second item is the file’s date; to convert this value to seconds consistent with file-seconds, pass the date string to ftp-make-file-seconds. The third string is the name of the file or directory. If the item is a file (the first string is "-"), and if the line that the server replied with has a size in the expected place, then a fourth string containing this size is included.

Warning: the FTP protocol has no specification for the reply format, so this information can be unreliable.

(ftp-make-file-seconds ftp-date)  exact-integer?
  ftp-date : string?
Takes a date string produced by ftp-directory-list and converts it to seconds (which can be used with seconds->date).

Warning: the FTP protocol has no specification for the reply format, so this information can be unreliable.

(ftp-download-file ftp-conn local-dir file)  void?
  ftp-conn : ftp-connection?
  local-dir : path-string?
  file : string?
Downloads file from the server’s current directory and puts it in local-dir using the same name. If the file already exists in the local directory, it is replaced, but only after the transfer succeeds (i.e., the file is first downloaded to a temporary file, then moved into place on success).

4.2 FTP Unit

ftp@ and ftp^ are deprecated. They exist for backward-compatibility and will likely be removed in the future. New code should use the net/ftp module.

 (require net/ftp-unit)

ftp@ : unit?
Imports nothing, exports ftp^.

4.3 FTP Signature

 (require net/ftp-sig)

ftp^ : signature

Includes everything exported by the net/ftp module.