## Generic data connection package
package Net
::FTP
::dataconn
;
use vars
qw(@ISA $timeout $VERSION);
@ISA = qw(IO::Socket::INET);
${*$data}{'net_ftp_bytesread'} = 0;
my $ftp = ${*$data}{'net_ftp_cmd'};
# no need to abort if we have finished the xfer
if ${*$data}{'net_ftp_eof'};
# for some reason if we continously open RETR connections and not
# read a single byte, then abort them after a while the server will
# close our connection, this prevents the unexpected EOF on the
if(exists ${*$data}{'net_ftp_bytesread'}
&& (${*$data}{'net_ftp_bytesread'} == 0)) {
my $timeout = $data->timeout;
$data->can_read($timeout) && sysread($data,$buf,1);
${*$data}{'net_ftp_eof'} = 1; # fake
$ftp->abort; # this will close me
my $ftp = ${*$data}{'net_ftp_cmd'};
delete ${*$ftp}{'net_ftp_dataconn'}
if exists ${*$ftp}{'net_ftp_dataconn'} &&
$data == ${*$ftp}{'net_ftp_dataconn'};
my $ftp = ${*$data}{'net_ftp_cmd'};
if(exists ${*$data}{'net_ftp_bytesread'} && !${*$data}{'net_ftp_eof'}) {
return $data->abort unless ${*$data}{'net_ftp_eof'};
$ftp->response() == CMD_OK
&&
$ftp->message =~ /unique file name:\s*(\S*)\s*\)/ &&
(${*$ftp}{'net_ftp_unique'} = $1);
my ($data, $timeout, $do_read) = @_;
my ($rin,$rout,$win,$wout,$tout,$nfound);
vec($rin='',fileno($data),1) = 1;
($win, $rin) = ($rin, $win) unless $do_read;
$nfound = select($rout=$rin, $wout=$win, undef, $tout=$timeout);
${*$ftp}{'net_ftp_bytesread'} || 0;