anna_black has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I'm using IO::Select in order to switch between different clients connected to the same server program. At first, I used a sample code to understand how IO::Select works. That code uses the select() method in order to find the clients that have produced some output, like this:
$read_set = new IO::Select(); # create handle set for reading $read_set->add($socket); # add the main socket to the set # Get a set of readable handles (blocks until at least one handle is r +eady) my ($rh_set) = IO::Select->select($read_set, undef, undef, 0);
Now, after reading the module's documentation, I'm trying to understand what's the difference between using can_read() and select(). Can the last line in the above extract be written as my @rh_set = $read_set->can_read(); ?
I can see that one method is static whole the other is not, and that one returns references to arrays, while the second returns one array - but are there any differences in the results themselves? Is one of them somehow "better" to use than the other?
Thanks a lot!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Difference between can_read() and select() in IO::Select
by balakrishnan (Monk) on Feb 25, 2009 at 15:31 UTC | |
by mr_mischief (Monsignor) on Feb 25, 2009 at 16:29 UTC | |
|
Re: Difference between can_read() and select() in IO::Select
by zentara (Cardinal) on Feb 25, 2009 at 15:39 UTC | |
|
Re: Difference between can_read() and select() in IO::Select
by targetsmart (Curate) on Feb 25, 2009 at 16:42 UTC | |
by chromatic (Archbishop) on Feb 25, 2009 at 19:24 UTC | |
by zentara (Cardinal) on Feb 25, 2009 at 16:57 UTC | |
|
Re: Difference between can_read() and select() in IO::Select
by Anonymous Monk on Feb 25, 2009 at 15:29 UTC | |
by ikegami (Patriarch) on Feb 25, 2009 at 15:41 UTC |