2 ## Package to read/write on BINARY data connections
13 use Net::FTP::dataconn;
15 our @ISA = qw(Net::FTP::dataconn);
16 our $VERSION = "3.07";
24 my $size = shift || croak 'read($buf,$size,[$timeout])';
25 my $timeout = @_ ? shift: $data->timeout;
29 if ($size > length ${*$data} and !${*$data}{'net_ftp_eof'}) {
30 $data->can_read($timeout)
33 my $blksize = ${*$data}{'net_ftp_blksize'};
34 $blksize = $size if $size > $blksize;
36 unless ($n = sysread($data, ${*$data}, $blksize, length ${*$data})) {
37 return unless defined $n;
38 ${*$data}{'net_ftp_eof'} = 1;
42 $buf = substr(${*$data}, 0, $size);
46 substr(${*$data}, 0, $n) = '';
48 ${*$data}{'net_ftp_bytesread'} += $n;
58 my $size = shift || croak 'write($buf,$size,[$timeout])';
59 my $timeout = @_ ? shift: $data->timeout;
61 # If the remote server has closed the connection we will be signal'd
62 # when we write. This can happen if the disk on the remote server fills up
64 local $SIG{PIPE} = 'IGNORE'
65 unless ($SIG{PIPE} || '') eq 'IGNORE'
70 my $blksize = ${*$data}{'net_ftp_blksize'};
72 $data->can_write($timeout)
75 my $n = syswrite($data, $buf, $sent > $blksize ? $blksize : $sent, $off);
76 return unless defined($n);