The code as presented is confusing to me. That may be my fault as I am no authority on event loops. However, since nobody else has replied yet it may be that they are confused as well. If you could maybe address these questions I have then it might encourage others to chip in too.

  1. You are using both IO::Async and AnyEvent but not using either of the glue modules I would expect to see (AnyEvent::Impl::IOAsync or IO::Async::Loop::AnyEvent). Could you explain this?
  2. The code appears to want to ping the same set of hosts twice on different schedules. I cannot think of any reason to do this. What is your intention here?
  3. Within each timer you are pinging 254 addresses 4 times with a 2 second timeout on each. Any target which drops the packets will therefore take 8 seconds to complete. And yet your timers are each on a hard reschedule of less than 8 seconds. Even if your code worked without blocking you could end up with a ping bomb. Again, without knowing your intention it is hard to advise further.

If you could give a clear statement of your intended algorithm it would help me (and maybe others) to be in a position to help you more.

Update: removed reference to IO::Async::Loop::AnyEvent as newer versions of AnyEvent explicitly prevent its use.


In reply to Re: Implementing AnyEvent::Ping multiple times by hippo
in thread Implementing AnyEvent::Ping multiple times by mmoorreett

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.