4 FTP: Client Downloading

▼ |  | Net: Racket 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

( 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 |  |  |  |
|  | 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 username and password strings are encoded to bytes using the current locale’s encoding.

( 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 (encoded using the current locale’s encoding); it must not contain a newline.

( ftp-directory-list ftp-conn)

→

( listof ( list/c ( one-of/c "-" "d" "l")
string?
string?))

ftp-conn : ftp-connection?

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.

Each file or directory is represented by a list of three 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, below. The third string is the name of the file or directory.

All strings are decoded from bytes using the current locale’s encoding.

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

( 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

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

top← prev up next →