Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

How move on to next ip if no connection got established?

by harry_ (Initiate)
on Jun 04, 2001 at 19:56 UTC ( #85515=perlquestion: print w/replies, xml ) Need Help??

harry_ has asked for the wisdom of the Perl Monks concerning the following question:

Dear perl-coders, Sorry if this question has been answered in the past. I am writing a program which checks the httpd version of random ip's (generated by the program). How can I can I make $0 move on to next ip, if no connection got established in a 5 sec wait? (I am not using IO::Socket) Sincerely yours, Harry.
  • Comment on How move on to next ip if no connection got established?

Replies are listed 'Best First'.
Re: How move on to next ip if no connection got established?
by Henri Icarus (Beadle) on Jun 04, 2001 at 22:59 UTC
    As long as you are on a unix system that handles signals you can use this:
    $seconds_allowed_to_do_task = 5; foreach (@list_of_things_to_do) { eval { local $SIG{ALRM} = sub { die "dead"}; alarm $seconds_allowed_to_do_task; &doTask($_); alarm 0; }; }
    The eval loop get's killed by the "die" after the alarm goes off (if it does). So just put your IP address in the list, and make doTask be the function that does your http connection. -Henri

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://85515]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2023-03-26 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (63 votes). Check out past polls.

    Notices?