I'm trying to speed up communication to a bunch of WHOIS servers by using IO::Select - the theory being that it is better to make 100 queries and then sit around for the results, than to make each query one by one and wait for each result sequentially. But instead of speeding up, my code is timing out the web server! I must be doing something dumb, but I can't figure out what.

Here's the stuff:

# 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; }; }
Am I being stupid in mixing sysreads with IO::Selects? Or not checking for something obvious?

Thanks

dave hj~


In reply to slow, slow IO::Select by dash2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.