multiple whois queries

I would like to build a program which will be able to ask internic for a whois then ask the autoritive registrar's whois server for information and loop it 50 times (max).  I have been using a command line program which works very well except for the occasional "Can't print to server" error.  I hve three questions:
1.  Is there a way to keep a channel open for multiple queries?
2.  How does one keep the program working after such an error?
3.  Using the following script how does one change the whois server dynamically?

my $out=whois($host);

print $out;

sub whois {
   my $sock = IO::Socket::INET->new(
   PeerAddr => ($_[1]?$_[1]:'whois.publicinterestregistry.net'),
   PeerPort => 'whois(43)',
   Proto    => 'tcp',
   Timeout  => 60) or die "IO::Socket::INET: $!";

   $sock->print($_[0],"\r\n");
   my @result=$sock->getlines;
   $sock->close;
   return wantarray?@result:join('',@result);
}

Thanks for your help.
blenkhnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TintinCommented:
0
TrevizeCommented:
1. No, the WHOIS protocol doesn't have this possibility.

2. Automatic retry:

my $out;
for (1..10)
{
   eval
   {
      $out = whois($host);
   };

   last unless $@;  # stop trying if successful

   sleep(1);        # wait 1 seconds before next try
}

if (defined $out)
{
   print $out;
}
else
{
   print STDERR "Could not retrieve domain information";
}

3. Do you mean this:

out = whois($host, "whois.something.net");
0
blenkhnAuthor Commented:
Thanks for your reply,

With using the statement

out = whois($host, "whois.something.net");

do I still need to have the statement

 PeerAddr => ($_[1]?$_[1]:'whois.publicinterestregistry.net').

How do I change the script to do this?

0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

TrevizeCommented:
You don't need to change anything - either you set the whois server explicitly when calling the whois() function or it uses the default server (whois.publicinterestregistry.net).
0
blenkhnAuthor Commented:
Thanks for your reply,

With using the statement

out = whois($host, "whois.something.net");

do I still need to have the statement

 PeerAddr => ($_[1]?$_[1]:'whois.publicinterestregistry.net').

How do I change the script to do this?

0
TrevizeCommented:
You don't need to change anything - either you set the whois server explicitly when calling the whois() function or it uses the default server (whois.publicinterestregistry.net).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
blenkhnAuthor Commented:
I have used your suggestion to cancel out the errors occuring from the whois server.  what about transmission errors?  maybe a timer to rehit the server after so long? How would one check to see if the complete record has been received?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.