My problem is about using perl to ftp a local file to the ftp server. The question is why the upload speed is so slow. Here is code:
use strict;
use warning;
use NET::FTP;
my $ftpserver = "10.110.143.9";
my $usr = "John";
my $passwd = "John";
sub main {
my $ftp = Net::FTP->new( $ftpserver, Timeout => 200 ) or print "Can't connect ftpserver" sleep 5;
my $rc = $ftp->login( $usr, $passwd );
unless ($rc) {
print("login failed!");
return 1;
}
print("login success");
$ftp->binary();
$ftp->put("d:\\2012.txt");
$ftp->quit;
return 0;
}
Upload times for 30mb are about 5 minutes while using another ftp client on the same machine takes only 10 seconds or so.
You should enable PassiveMode
, and also play with BlockSize
(it used to be a source for slowdown with Net::FTP
), something like this:
my $ftp = new Net::FTP(
$ftpserver,
Timeout => 200,
Passive => 1,
BlockSize => 8192,
);
Try increasing (or decreasing) BlockSize
by factor of 2 few times and see if it changes anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With