Net::FT...econnect(3)

πŸ“¦
version 0.3 Β· 4 versions
, in epel 9

πŸ’– NAME πŸ’–

okay bestie, this is the Net::FT...econnect(3) page from the User Contributed Perl Documentation, and it's serving Net::FTP::AutoReconnect realness: an FTP client class with automatic reconnect on failure. πŸ’…

✨ SYNOPSIS ✨

Net::FTP::AutoReconnect is a wrapper module around Net::FTP. For many commands, if anything goes wrong on the first try, it tries to disconnect and reconnect to the server, restore the state to the same as it was when the command was executed, then execute it again. The state includes login credentials, authorize credentials, transfer mode (ASCII or binary), current working directory, and any restart, passive, or port commands sent. no cap, it's giving "try again with your whole vibe intact" energy. 🫢

🌸 DESCRIPTION 🌸

The goal of this method is to hide some implementation details of FTP server systems from the programmer. In particular, many FTP systems will automatically disconnect a user after a relatively short idle time or after a transfer is aborted. In this case, Net::FTP::AutoReconnect will simply reconnect, send the commands necessary to return your session to its previous state, then resend the command. If that fails, it will return the error.

It makes no effort to determine what sorts of errors are likely to succeed when they're retried. Partly that's because it's hard to know; if you're retreiving a file from an FTP site with several mirrors and the file is not found, for example, maybe on the next try you'll connect to a different server and find it. But mostly it's from laziness; if you have some good ideas about how to determine when to retry and when not to bother, by all means send patches.

This module contains an instance of Net::FTP, which it passes most method calls along to.

These methods also record their state: alloc, ascii, authorize, binary, cdup, cwd, hash, login, restart, pasv, port. Directory changing commands execute a pwd afterwards and store their new working directory. cute little state hoarders, honestly. πŸ“

These methods are automatically retried:

  • alloc
  • appe
  • append
  • ascii
  • binary
  • cdup
  • cwd
  • delete
  • dir
  • get
  • list
  • ls
  • mdtm
  • mkdir
  • nlst
  • pasv
  • port
  • put
  • put_unique
  • pwd
  • rename
  • retr
  • rmdir
  • size
  • stou
  • supported

These methods are tried just once: abort, authorize, hash, login, pasv_xfer, pasv_xfer_unique, pasv_wait, quit, restart, site, unique_name. From Net::Cmd: code, message, ok, status. restart doesn't actually send any FTP commands (they're sent along with the command they apply to), which is why it's not restarted. periodt. ✨

Any other commands are unimplemented (or possibly misdocumented); if I missed one you'd like, please send a patch. (That "I" is the page author speaking, not me, bestie. 😭)

πŸ›  CONSTRUCTOR πŸ› 

new

All parameters are passed along verbatim to Net::FTP, as well as stored in case we have to reconnect. lowkey packing a little emergency go-bag. πŸŽ’

🧚 METHODS 🧚

Most of the methods are those of Net::FTP. The page says one additional method is available, and then lists these:

  • reconnect() β€” Abandon the current FTP connection and create a new one, restoring all the state we can. main character energy: out with the old, in with the restored. πŸ‘‘
  • disconnect() β€” Disconnect the current FTP connection abruptly. Mostly useful for testing. dramatic exit, but make it QA. πŸ’€
  • connect_count() β€” Return the number of times we have connected or reconnected to this server. Mostly useful for testing. literally counting the reconnects like a vibe check. πŸ”’

πŸ‘‘ AUTHOR πŸ‘‘

Scott Gifford <sgifford@suspectclass.com>

πŸ’€ BUGS πŸ’€

We should really be smarter about when to retry. ngl, the page says this itself.

We shouldn't be hardwired to use Net::FTP, but any FTP-compatible class; that would allow all modules similar to this one to be chained together. that's the dream, fr fr. 🌈

Much of this is only lightly tested; it's hard to find an FTP server unreliable enough to test all aspects of it. It's mostly been tested with a server that dicsonnects after an aborted transfer, and the module seems to work OK. (Yes, dicsonnects is how it's spelled on the page. iconic typo behavior.) 😭

πŸ¦‹ SEE ALSO πŸ¦‹

Net::FTP.

Copyright (c) 2006 Scott Gifford. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


cute lil' sign-off bestie: this page is from perl v5.32.1, dated 2023-01-04, and it's the Net::FT...econnect(3) page. mwah πŸ’‹πŸ«Ά

πŸ“¦ where this page comes from