2 ## Package to read/write on BINARY data connections
7 use vars qw(@ISA $buf $VERSION);
10 require Net::FTP::dataconn;
12 @ISA = qw(Net::FTP::dataconn);
20 my $size = shift || croak 'read($buf,$size,[$timeout])';
21 my $timeout = @_ ? shift: $data->timeout;
25 if ($size > length ${*$data} and !${*$data}{'net_ftp_eof'}) {
26 $data->can_read($timeout)
29 my $blksize = ${*$data}{'net_ftp_blksize'};
30 $blksize = $size if $size > $blksize;
32 unless ($n = sysread($data, ${*$data}, $blksize, length ${*$data})) {
33 return undef unless defined $n;
34 ${*$data}{'net_ftp_eof'} = 1;
38 $buf = substr(${*$data}, 0, $size);
42 substr(${*$data}, 0, $n) = '';
44 ${*$data}{'net_ftp_bytesread'} += $n;
54 my $size = shift || croak 'write($buf,$size,[$timeout])';
55 my $timeout = @_ ? shift: $data->timeout;
57 # If the remote server has closed the connection we will be signal'd
58 # when we write. This can happen if the disk on the remote server fills up
60 local $SIG{PIPE} = 'IGNORE'
61 unless ($SIG{PIPE} || '') eq 'IGNORE'
66 my $blksize = ${*$data}{'net_ftp_blksize'};
68 $data->can_write($timeout)
71 my $n = syswrite($data, $buf, $sent > $blksize ? $blksize : $sent, $off);
72 return undef unless defined($n);