Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Net::FTP get problem

by rob_au (Abbot)
on Jun 18, 2002 at 06:48 UTC ( [id://175295]=note: print w/replies, xml ) Need Help??


in reply to Net::FTP get problem (unexpected EOF)

While there's not quite enough here for me to be sure, my strong guess is that you are experiencing the same problem as described here - If indeed, you are facing the same issue, it is the result of not so much your script, but your network configuration and specifics of the FTP protocol.

When connecting to a FTP server, two socket streams are used for communications - The first is the control connection initiated by your FTP client between which the FTP client and server exchange commands and replies (TCP socket 21). The second is a full-duplex connection over which data is transferred in a specified mode and type. The data transferred may be part of a file, an entire file or a listing of files within a directory. Typically, this data port is the port adjacent to the control port (TCP socket 20).

In general, it is the FTP server's responsibility to initiate and maintain the data connection. It is here that your script is running into problems.

This host address, along with the preferred socket for data communications, are sent to the server via the PORT command. I suspect that you are in fact connecting to a live Internet host with this script through a network firewall or layer of address translation and as such, the data connection from the server to your machine is failing because the FTP server is unable to reach your private machine.

The means by which to fix this is to switch to passive FTP transfer mode via the PASV command - This command changes the default behaviour of data port negotiation, shifting the onus for responsibility for data port establishment and maintenance back to the client. This allows the client to control its only data connection through the network firewall or translation layer, allowing normal FTP communications to occur. eg.

use Net::FTP; # Passive mode can be set with object initiation my $ftp = Net::FTP->new( $hostname, Debug => 1, Passive => 1 ) or die +$!; $ftp->login( $user, $password ); # Or with $object->pasv; $ftp->pasv;

Further information on this topic can be found in RFC documents (0959) File Transfer Protocol, (1122) Requirements for Internet hosts - communication layers and (1579) Firewall-Friendly FTP.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://175295]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-04-19 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found