@ret = InCharge::session::select(\@observerList, $timeout);
The select() function checks if there are data to be read for each observer in @observerList.
@ret returns a list of handles in which the value:
-
1 represents that the observer has data to read
-
0 indicates that there are no data to be read.
The $timeout parameter indicates how many seconds the function select should wait before returning the result. It can be called with an undef value for no wait time.
Example of usage:
@ret = InCharge::session::select(<ref_list>,<timeout>);
where:
-
<ref_list> is a reference to the list of observers that will be checked.
-
<timeout> is the number of seconds to wait before returning. For immediate return, use the argument undef.
The following script returns an array with the result for each checked observer.
use InCharge::session; use Data::Dumper; my %common = ( user => "admin", password => "changeme"); $mask = ""; $i=0; foreach $dom ( "INCHARGE-AM", "INCHARGE-SA" ) { $sess{$dom} = InCharge::session->new( %common, domain => $dom ); $obs{$dom} = $sess{$dom}->observer( ); @obsList[$i]= $obs{$dom}; $sess{$dom}->subscribe( ".*::.*::.*/pa" ); #$fn{$dom} = $obs{$dom}->getFileno()."\n"; #vec($mask, $fn{$dom}, 1) = 1; $i++; } $i=0; for ( ; ; ) { $i=0; @obsRet = InCharge::session::select( \@obsList, undef); foreach $obsR ( @obsRet ) { #next unless (vec($rout, $fn{$dom}, 1)); @event = $obsR->receiveEvent( ); print "$obsR->{domain} - ".join( ", ", @event ). "\n"; $i++; }
}