dash2 has asked for the wisdom of the Perl Monks concerning the following question:
Here's the stuff:
Am I being stupid in mixing sysreads with IO::Selects? Or not checking for something obvious?# create a nice IO::Select object with a bunch of sockets... then while ( my @ready = $select->can_read(30) ) { foreach (@ready) { my $result = sysread($_, $domains{$_}[2], 128$domains{$_}[3]); # do +mains is just a local data structure where elements [2] and [3] are t +he WHOIS results returned so far, and the offset unless (defined $result){ $domains{$_}[0]{result} = "no_connect"; $select -> remove($_); $_->close; next; }; if ( $domains{$_}[2] =~ /$domains{$_}[1]/ ) { $domains{$_}[0]{result} = "avail"; $select -> remove($_); $_->close; next; } unless ($result) { $domains{$_}[0]{result} = "unav"; $select -> remove($_); $_->close; next; } $domains{$_}[3] += $result; } foreach ($select -> has_exception ) { $select->remove($_); $_->close; }; }
Thanks
dave hj~
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: slow, slow IO::Select
by dash2 (Hermit) on Mar 13, 2001 at 06:29 UTC | |
by AgentM (Curate) on Mar 13, 2001 at 06:38 UTC | |
by tye (Sage) on Mar 13, 2001 at 21:11 UTC |