We have a little bit misunderstanding of retr() here ;-), and retr() absolutely does not provide you the kind of control you are looking for, over file transfer.
FTP involves two TCP connections, control connection and data connection. When you do things such like LIST etc., the control connection is used. When you do get() or retr(), the data connection is used.
For the control connection, it is always the FTP server listens for TCP connection, and your client connects to the server.
For the data connection, there are two modes:
- active mode (default). In this mode, the FTP client (your script) listens for TCP connection, and the FTP server side connects to you.
- passive mode. In this mode, the FTP server listens for TCP connection, and your client script connects to the server.
Internally, both get() and retr() resolve to the same FTP command "RETR", but before retr(), the two sides of FTP would negotiate and go to passive mode. In both mode, Net::FTP has full control of socket reading and writing, not your script.
There is no way Net::FTP can provide what
allyc wants. To subclass Net::FTP sounds reasonable.