rementis has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Timout a gethostbyaddr?
by shigetsu (Hermit) on Mar 22, 2007 at 23:15 UTC | |
by rementis (Beadle) on Mar 23, 2007 at 01:18 UTC | |
by Anonymous Monk on Mar 23, 2007 at 05:11 UTC | |
|
Re: Timout a gethostbyaddr?
by Zaxo (Archbishop) on Mar 23, 2007 at 03:40 UTC | |
|
Re: Timout a gethostbyaddr?
by ikegami (Patriarch) on Mar 22, 2007 at 23:15 UTC | |
|
Re: Timout a gethostbyaddr?
by shmem (Chancellor) on Mar 22, 2007 at 23:28 UTC | |
|
Re: Timout a gethostbyaddr?
by salva (Canon) on Mar 23, 2007 at 08:22 UTC | |
by almut (Canon) on Mar 23, 2007 at 14:14 UTC | |
|
Re: Timout a gethostbyaddr?
by almut (Canon) on Mar 23, 2007 at 14:06 UTC |