dunno about the select module, but a normal call to select will block.
that is why in my other mail i had given you the option of blocking on
select in another thread/process
/kk
On Fri, Jun 29, 2001 at 12:36:20PM -0400, Ronald J. Yacketta wrote:
> Maybe I just don't understand..
> but wont there _always_ be data to read from netstat?
> to me, it seems as tho the loop _not_ work as intended, it
> would always pass the can_read and read data from netstat and
> never parse the other code?
>
> Regards,
> Ron
>
> > -----Original Message-----
> > From: David M. Lloyd [mailto:[EMAIL PROTECTED]]
> > Sent: June 29, 2001 10:37
> > To: Ronald J. Yacketta
> > Cc: Perl
> > Subject: RE: background processing (again?)
> >
> >
> > 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]>
> >
> >
> >