▼ |  | Net: Networking Libraries

1 | URLs and HTTP
2 | URI Codec: Encoding and Decoding URIs
3 | Web Socket
4 | FTP: Client Downloading
5 | Send URL: Opening a Web Browser
6 | SMTP: Sending E-Mail
7 | sendmail: Sending E-Mail
8 | Headers: Parsing and Constructing
9 | IMAP: Reading Mail
10 | POP3: Reading Mail
11 | MIME: Decoding Internet Data
12 | Base 64: Encoding and Decoding
13 | Quoted-Printable: Encoding and Decoding
14 | DNS: Domain Name Service Queries
15 | NNTP: Newsgroup Protocol
16 | TCP: Unit and Signature
17 | TCP Redirect: tcp^ via Channels
18 | SSL Unit: tcp^ via SSL
19 | CGI Scripts
20 | Cookie: HTTP Client Storage
| Bibliography
| Index

► | 4 | FTP: Client Downloading

4.1 | Functions
4.2 | FTP Unit
4.3 | FTP Signature

On this page:

4.1`` Functions
ftp-connection?
ftp-establish-connection
ftp-close-connection
ftp-cd
ftp-directory-list
ftp-make-file-seconds
ftp-download-file
4.2`` FTP Unit
ftp@
4.3`` FTP Signature
ftp^

top← prev up next →

### 4`` FTP: Client Downloading

(require net/ftp)

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

#### 4.1`` Functions

> > procedure

> > (ftp-connection? v) → boolean?

> v : any/c

Returns #t if v represents an FTP connection as returned by ftp-establish-connection, #f otherwise.

> > procedure

> > (ftp-establish-connection |  | server |  |  |  |
> > |  | port-no |  |  |  |
> > |  | user |  |  |  |
> > |  | 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.

> > procedure

> > (ftp-close-connection ftp-conn) → void?

> ftp-conn : ftp-connection?

Closes an FTP connection.

> > procedure

> > (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.

> > 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

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.

> > procedure

> > (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.

> > procedure

> > (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)

> > value

> > ftp@ : unit?

Imports nothing, exports ftp^.

#### 4.3`` FTP Signature

(require net/ftp-sig)

> > signature

> > ftp^ : signature

Includes everything exported by the net/ftp module.

top← prev up next →