От: | Spider84 | http://spider.vc | |
Дата: | 01.06.10 21:33 | ||
Оценка: |
open (PINGTEST, "/bin/ping 192.168.0.1 |");
my $ping = new IO::Handle;
$ping->fdopen(fileno(PINGTEST),"r");
my $stream = IO::Async::Stream->new(
handle => $ping,
autoflush => 1,
on_read => sub {
my ( $self, $buffref, $closed ) = @_;
print $$buffref;
return 0;
}
);
$timer->start;
$loop->add( $stream );
$loop->loop_forever()
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.069 ms
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.069 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.054 ms
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.069 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.054 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.052 ms