473,503 Members | 5,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

gethostbyaddr

23 New Member
I'm writing a script that takes a list of ipaddresses as input and converts them to hostnames.......

The problem here is some of the ip addresses do not resolve to their hostnames and for those ip addresses perl get hung and never goes to resolve the next given ipaddress....

Any suggestion is appreciated !
Expand|Select|Wrap|Line Numbers
  1. open (F,$filename) or die 'Cannot open file';
  2. while(<F>){
  3. push @sip,$_;
  4. }
  5. foreach $sip(@sip){
  6. chomp($sip);
  7. $packaddr = pack ("C4", split (/\./, $sip) );
  8. $ns = gethostbyaddr($packaddr, 2);
  9. print "$sip ------- $ns\n";
  10. close F;
  11.  
Jun 19 '08 #1
1 2949
karthikeyanck
23 New Member
I used the http://search.cpan.org/~patl/Time-Out-0.10/Out.pod, it works well with Linux systems, but doesn't work on windows, any help appreciated,
Expand|Select|Wrap|Line Numbers
  1. foreach $sip(@sip){
  2. $bcd = timeout $nb_sec => sub{
  3. chomp($sip);
  4. $packaddr = pack ("C4", split (/\./, $sip) );
  5. $ns = gethostbyaddr($packaddr, 2);
  6. print "$sip ------- $ns\n";
  7. }
  8. };
  9.  
Jun 19 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3250
by: O.B. | last post by:
What reasons are there for the following returning the IP address instead of the hostname? gethostbyaddr($_SERVER)
0
1609
by: Sibylle Koczian | last post by:
Hello all, the documentation for the socket module says that gethostbyaddr should return the primary host name and alternative host names if there are any. But the alias list is empty even in...
2
2672
by: Neil Aggarwal | last post by:
Hello: I am using gcc on RedHat Linux 9. When I try to do a reverse dns query using gethostbyaddr, it works fine for hosts that have a PTR record, but it returns null for hosts that have a...
1
4983
by: kcw3388 | last post by:
Hi, I have a SunOS TCP/IP client program worked fine for a long time until yesterday. Now, my TCP/IP server program is located on different DNS server. The gethostbyaddr ( ) is now...
2
3175
by: Harlin Seritt | last post by:
I have a list of IP addresses I am testing with socket.gethostbyaddr(). For the most part, I am able to get a hostname returned to me when I run gethostbyaddr(). I am also hoping this will allow me...
0
1410
by: Jørn Dahl-Stamnes | last post by:
I have a PHP script which contain the following code: $hostname = gethostbyaddr ($ip); Until yesterday, the gethostbyaddr returned the hostname of the given IP-addresse. But yesterday it began...
2
3079
by: christian9997 | last post by:
Hi Since yesterday about 11.00 CET the gethostbyaddr function doesn't seem to be working. All I get is the IP address back. Is this something general to all PHP users or is this specific to my...
1
3629
by: shailesh | last post by:
Hi, I am facing a peculiar problem. socket.gethostbyaddr is not working fine on my MAC for ip addresses on the LAN. The LAN happens to consist of linux and windows machines and this is the only...
1
3102
by: lakshmiraja | last post by:
hi, I came to know that gethostbyaddr is deprecated in Visual Studio 2005 by the introduction of getnameinfo function. Can i know the reason for the deprecation of gethostbyaddr function. Is...
24
2468
by: RJ_32 | last post by:
When there is no rDNS record on an IP address, then it might take a while for the reverse lookup to timeout. I'm thinking of how on a tracert you can observe the delay. If so, then calling...
0
7188
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7063
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6970
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7441
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3146
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1489
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.