I have what I think is going to be a simple question...
I have a subroutine that uses Socket, gethostbyaddr to resolve the hostname of an ip address. This subroutine needs to run about 35,000 times and unfortunately many of the times the hostname will not be found and the sub will timeout. This does not cause any problems except that it takes quite a few seconds to timeout, making the script run way longer than necessary. How can I make gethostbyaddr timeout sooner, say in 2 seconds? I found one solution in the Perl Cookbook using eval, alarm, and a SIGALRM handler, but I was hoping to see a better way to get this done. I am not married to gethostbyaddr by the way. Thanks in advance!
In reply to Timout a gethostbyaddr? by rementis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |