On Thu, 28 Jun 2001, Ronald J. Yacketta wrote:

> I have heard doing it this way will cause grief.. need blocking i/o or
> something along that lines. Also, I head that the flow of the program
> would _stop_ when reading the data...
> 
> are there any other solutions?

You can get around blocking I/O by using the IO::Select module:

### PERL

open NETSTAT, "netstat -I hme0 $SLEEPTIME |" or die "Can't start netstat: $!\n";

my $select = new IO::Select;

$select->add_reader(\*NETSTAT);

while (1) {

        if ($select->can_read(0)) {
            # There is data so read it
        } else {
            # do something else while we wait
        }
}

### END PERL

> P.S.
> kk, I never did get you example code working under Solaris, it works fine
> under Linux

If you're talking about my code, be aware that 'netstat' takes different
arguments based on which platform you're on.

- D

<[EMAIL PROTECTED]>


Reply via email to