Net-Netconf
view release on metacpan or search on metacpan
lib/Net/Netconf/Access/ssh.pm view on Meta::CPAN
my ($self, $xml) = @_;
$xml .= ']]>]]>';
my $len = length($xml);
$self->trace("Will write $len bytes to the SSH channel:");
$self->trace("$xml");
# Make the channel blocking, so the write() call below waits until there
# is available buffer space. Otherwise we'll end up busy-looping.
$self->{'chan'}->blocking(1);
my $written = 0;
while($written != $len) {
my $nbytes = $self->{'chan'}->write($xml)
or croak "Failed to write XML data to SSH channel!";
$written += $nbytes;
$self->trace("Wrote $nbytes bytes (total written: $written).");
substr($xml, 0, $nbytes) = '';
}
lib/Net/Netconf/Access/ssh.pm view on Meta::CPAN
# reads (as we can't possibly know if the data we're about to receive is an
# exact multiple of the buffer size argument, and doing it one character at
# a time instead would be terribly inefficient).
$chan->blocking(0);
$self->trace("Reading XML response from Netconf server...");
my ($resp, $buf);
my $end_time = time() + 15;
do {
# Wait up to 10 seconds for data to become available before attempting
# to read anything (in order to avoid busy-looping on $chan->read())
my @poll = ({ handle => $chan, events => 'in' });
$ssh2->poll(40000, \@poll);
$nbytes = $chan->read($buf, 65536);
if (!defined $nbytes || time() > $end_time) {
croak "Failed to read XML data from SSH channel!";
}
if($nbytes > 0){
$end_time = time() + 15;
( run in 0.246 second using v1.01-cache-2.11-cpan-87723dcf8b7 )