1Net::FTP::AutoReconnectU(s3e)r Contributed Perl DocumentaNteito:n:FTP::AutoReconnect(3)
2
3
4
6 Net::FTP::AutoReconnect - FTP client class with automatic reconnect on
7 failure
8
10 "Net::FTP::AutoReconnect" is a wrapper module around "Net::FTP". For
11 many commands, if anything goes wrong on the first try, it tries to
12 disconnect and reconnect to the server, restore the state to the same
13 as it was when the command was executed, then execute it again. The
14 state includes login credentials, authorize credentials, transfer mode
15 (ASCII or binary), current working directory, and any restart, passive,
16 or port commands sent.
17
19 The goal of this method is to hide some implementation details of FTP
20 server systems from the programmer. In particular, many FTP systems
21 will automatically disconnect a user after a relatively short idle time
22 or after a transfer is aborted. In this case,
23 "Net::FTP::AutoReconnect" will simply reconnect, send the commands
24 necessary to return your session to its previous state, then resend the
25 command. If that fails, it will return the error.
26
27 It makes no effort to determine what sorts of errors are likely to
28 succeed when they're retried. Partly that's because it's hard to know;
29 if you're retreiving a file from an FTP site with several mirrors and
30 the file is not found, for example, maybe on the next try you'll
31 connect to a different server and find it. But mostly it's from
32 laziness; if you have some good ideas about how to determine when to
33 retry and when not to bother, by all means send patches.
34
35 This module contains an instance of "Net::FTP", which it passes most
36 method calls along to.
37
38 These methods also record their state: "alloc", "ascii", "authorize",
39 "binary", "cdup", "cwd", "hash", "login","restart", "pasv", "port".
40 Directory changing commands execute a "pwd" afterwards and store their
41 new working directory.
42
43 These methods are automatically retried: "alloc", "appe", "append",
44 "ascii", "binary", "cdup", "cwd", "delete", "dir", "get", "list", "ls",
45 "mdtm", "mkdir", "nlst", "pasv", "port", "put", "put_unique", "pwd",
46 "rename", "retr", "rmdir", "size", "stou", "supported".
47
48 These methods are tried just once: "abort", "authorize", "hash",
49 "login", "pasv_xfer", "pasv_xfer_unique", "pasv_wait", "quit",
50 "restart", "site", "unique_name". From "Net::Cmd": "code", "message",
51 "ok", "status". "restart" doesn't actually send any FTP commands
52 (they're sent along with the command they apply to), which is why it's
53 not restarted.
54
55 Any other commands are unimplemented (or possibly misdocumented); if I
56 missed one you'd like, please send a patch.
57
58 CONSTRUCTOR
59 new
60
61 All parameters are passed along verbatim to "Net::FTP", as well as
62 stored in case we have to reconnect.
63
64 METHODS
65 Most of the methods are those of Net::FTP. One additional method is
66 available:
67
68 reconnect()
69
70 Abandon the current FTP connection and create a new one, restoring all
71 the state we can.
72
73 disconnect()
74
75 Disconnect the current FTP connection abruptly. Mostly useful for
76 testing.
77
78 connect_count()
79
80 Return the number of times we have connected or reconnected to this
81 server. Mostly useful for testing.
82
84 Scott Gifford <sgifford@suspectclass.com>
85
87 We should really be smarter about when to retry.
88
89 We shouldn't be hardwired to use "Net::FTP", but any FTP-compatible
90 class; that would allow all modules similar to this one to be chained
91 together.
92
93 Much of this is only lightly tested; it's hard to find an FTP server
94 unreliable enough to test all aspects of it. It's mostly been tested
95 with a server that dicsonnects after an aborted transfer, and the
96 module seems to work OK.
97
99 Net::FTP.
100
102 Copyright (c) 2006 Scott Gifford. All rights reserved. This program is
103 free software; you can redistribute it and/or modify it under the same
104 terms as Perl itself.
105
106
107
108perl v5.36.0 2023-01-20 Net::FTP::AutoReconnect(3)