Hi,

Question about Net::Pcap which may also be a general PERL question.
What I want to do is:
1. Capture a fixed number of ethernet packets
2. If the fixed number of ethernet packets doesn't arrive move on gracefully trapping the fact that they didn't arrive.

Here's my code attempt:
eval { local $SIG{'ALRM'} = sub {Net::pcap::breakloop($$ref2pcap_mas +ter);}; alarm 10; # Capture two messages outgoing and incoming Net::Pcap::loop($$ref2pcap_master, 2, \&do_eth_init_process, +\$init_fail); alarm 0; };
Note: $$ref2pcap_master is my pcap object.

I've managed to get 1) to work i.e. my Net::Pcap callback function is called correctly, I'm happy with this.

My problem is catching the case when no packets arrive. The alarm() function doesn't seem to work for me i.e. I would have thought after 10 seconds if I didn't get two packets that I would have moved on because I call Net::Pcap::breakloop in the alarm signal function.

Apologies for my lack of terminology, i code FPGAs and design PCBs for a living, I am a PERL hacker in the true sense of the word "hack".

Thanks,
umballah.

In reply to Killing Net::pcap::loop by umballah

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.