473,569 Members | 2,752 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 2957
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
3255
by: O.B. | last post by:
What reasons are there for the following returning the IP address instead of the hostname? gethostbyaddr($_SERVER)
0
1622
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 cases where I know aliases exist. I can get them using gethostbyname_ex, but that only works with names, not with IP addresses, and I want to resolve...
2
2683
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 CNAME record. Any ideas how to work around this? Here is an example: dig -x 66.54.79.4
1
4984
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 returned NULL instead.
2
3186
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 to tell if a computer is up or down. However, in my environment, I am finding that I am able to get a hostname even though I am unable to actually...
0
1414
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 to return the name of the host the web-server is running on regardless of the given IP. If I do a 'host <IP>' from a shell on the same machine, I...
2
3088
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 server? Thanks BTW what's the difference between comp.lang.php, alt.php and alt.comp.lang.php, shouldn't these groups be merged?
1
3632
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 one MAC on the LAN. Please see the example below. I am getting error: socket.herror: (1, 'Unknown host')
1
3107
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 there any security issues related with this function? Also came to know that calling this function is not thread safe. I am not able to get the exact...
24
2476
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 gethostbyaddr() can delay the serving of the web page, right? Because gethostbyaddr() is not forked into a separate process. So I suppose I'd need to...
0
7694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6278
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
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 we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.