do { $ftp->restart($transferred); ++$attempts; if($attempts>2){ mesg('*',"Having trouble writing to server, on attempt $attempts...",$evqueue); } $written=$dataconn->write($buffer,$to_transfer,$config->{'timeout'}); if($attempts>$soft_retries){ mesg('*',"Connection appears to be dead. Attempting to re-start...",$evqueue); $ftp=undef; $ftp=ftp_transfer::connect($config,$evqueue) while(not defined $ftp); $ftp->binary; $ftp->restart($transferred); } } while($written<$to_transfer); $transferred+=$written;