I came across an old(er) snippet of code I used a while back for a tcp server with IO::Socket and IO::Select. It used the IO::Select::select() method to get a list of clients that could be read from. I swear I've always used can_read() instead, but apparently not! So my question is quite very simple: do the two snippets below do the exact same thing? If so, great, I think I'll stick with can_read. If they differ in any manner, does anyhow have the knowledge to share with me the difference(s) between the two methods?
I did a quick perldoc -m IO::Select and found the can_read() sub. It looks quite the same (ie: it utilizes select() in the same way), but with all the vector bits tech stuff thrown in, I can't tell exactly what's going on.
# Snippet One: select()
while (my ($read) =
IO::Select::select($clients, undef, undef, undef)
) {
for my $client (@$read) {
# handle this
}
}
# Snippet Two: can_read()
while (my @read = $clients->can_read()) {
for my $client (@read) {
# handle this
}
}
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.