in reply to open,select,sysread for non-blocking traceroute

select only works on sockets in Windows.

Replies are listed 'Best First'.
Re^2: open,select,sysread for non-blocking traceroute
by Proclus (Beadle) on Jun 02, 2009 at 18:59 UTC
    Hmmmm. Thanks ikegami.
    Any idea about what I can use to get data from open()'ed filehandle without blocking the program?
    ------------------------------ "geneva will not marry you no matter how much you love Larry Wall." Geneva Wall
      Looks like I'm not alone. Looking through this now: http://www.perlmonks.org/?node_id=621058
        I got my solution. This is a true work of art dear monks: Thanks to BrowserUK!!
        use strict; use strict; use threads; use Thread::Queue; use Time::HiRes qw(usleep); $| =1 ; sub pipeCommand { my $Q = new Thread::Queue; async{ my $mypipe; my $pid = open($mypipe, '-|', "traceroute 66.186.184.205"); $Q->enqueue( $_ ) while <$mypipe>; $Q->enqueue( undef ); }->detach; return $Q; } my $pipe = pipeCommand() or die; while(1) { if( $pipe->pending ) { my $line = $pipe->dequeue or last; chomp( $line ); print $line,$/; } else { # Ogla's thread # my $msg = $network_thread->dequeue_nb(); # if($msg eq "EXIT"){ # $pipe->enqueue( undef ); # return undef; # } usleep(100_000); } }
        ------------------------------
        "Geneva will not marry you no matter how much you love Larry Wall." Geneva Wall