CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
time out for a function


New User

Feb 4, 2009, 4:09 AM

Post #1 of 3 (3120 views)
time out for a function Can't Post

How can i add timeout for the following ?

my code capture the packets.

i am using Net::Pcap::open_live and Net::Pcap::loop.

But how can i specify a time out to the loop.

for example if there are no packets for a given time the function should exit.

Veteran / Moderator

Feb 4, 2009, 5:00 AM

Post #2 of 3 (3115 views)
Re: [rameshgsl] time out for a function [In reply to] Can't Post

perldoc -q timeout

Found in /usr/lib/perl5/5.10.0/pod/perlfaq8.pod
How do I timeout a slow event?

Use the alarm() function, probably in conjunction with a signal handler, as documented in "Signals" in perlipc and the section on "Signals" in the
Camel. You may instead use the more flexible Sys::AlarmCall module available from CPAN.

The alarm() function is not implemented on all versions of Windows. Check the documentation for your specific version of Perl.


Feb 5, 2009, 7:13 AM

Post #3 of 3 (3098 views)
Re: [rameshgsl] time out for a function [In reply to] Can't Post

The open_live function can have a timeout passed into it as an argument.


If it aint broke then don't try to fix it


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives