4 FTP: Client
4.1 Functions
procedure
(ftp-connection? v) → boolean?
v : any/c
procedure
(ftp-establish-connection server port-no user passwd) → ftp-connection? server : string? port-no : (integer-in 0 65535) user : string? passwd : string?
procedure
(ftp-close-connection ftp-conn) → void?
ftp-conn : ftp-connection?
procedure
ftp-conn : ftp-connection? new-dir : string?
procedure
(ftp-directory-list ftp-conn [path])
→
(listof (list/c (one-of/c "-" "d" "l") string? string?)) ftp-conn : ftp-connection? path : (or/c false/c string?) = #f
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.
procedure
(ftp-make-file-seconds ftp-date) → exact-integer?
ftp-date : string?
Warning: the FTP protocol has no specification for the reply format, so this information can be unreliable.
procedure
(ftp-download-file ftp-conn local-dir-or-port file [ #:progress progress-proc]) → void? ftp-conn : ftp-connection?
local-dir-or-port :
(or/c path-string? output-port?) file : string?
progress-proc :
(or/c #f (-> (-> (values exact-nonnegative-integer? evt?)) any)) = #f
When local-dir-or-port is an output-port?, it downloads file from the server’s current directory and writes its content to provided output-port?. The data is written to the port as it is being received from the server and if the download is interrupted, incomplete data is written to the port. The port is closed after finishing the transfer.
If progress-proc is not #f, then it is called with a function get-count that returns two values: the number of bytes transferred so far, and an event that becomes ready when the transferred-bye count changes. The get-count function can be called in any thread and any number of times. The progress-proc function should return immediately, perhaps starting a thread that periodically polls get-count. Do not poll too frequently, or else polling will slow the transfer; the second argument from get-count is intended to limit polling.
(ftp-download-file ftp-conn "." "testfile" #:progress (lambda (get-count) (thread (lambda () (let loop () (define-values (count changed-evt) (get-count)) (printf "~a bytes downloaded\n" count) (sync changed-evt) (loop))))))
procedure
(ftp-upload-file ftp-conn file-path [ port #:progress progress-proc]) → void? ftp-conn : ftp-connection? file-path : path-string? port : (or/c #f input-port?) = #f
progress-proc :
(or/c #f (-> (-> (values exact-nonnegative-integer? evt?)) any)) = #f
If port is an input-port?, the content of that port is streamed as upload to the server and stored under given file-path name. The port is closed after finishing the transfer.
procedure
(ftp-delete-file ftp-conn file-path) → void?
ftp-conn : ftp-connection? file-path : path-string?
procedure
(ftp-make-directory ftp-conn dir-name) → void?
ftp-conn : ftp-connection? dir-name : string?
procedure
(ftp-delete-directory ftp-conn dir-name) → void?
ftp-conn : ftp-connection? dir-name : string?
procedure
(ftp-rename-file ftp-conn origin dest) → void?
ftp-conn : ftp-connection? origin : string? dest : string?
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) | package: compatibility-lib |
value
ftp@ : unit?
4.3 FTP Signature
(require net/ftp-sig) | package: compatibility-lib |
signature
ftp^ : signature
Includes everything exported by the net/ftp module.