473,406 Members | 2,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DNS.GetHostByAddress Question

When I make the following call:

IPHostEntry hostInfo = Dns.GetHostByAddress( hostIPAddress ) ;

If the PTR (i.e. the IP address to name resolution) does not exist my
program will start making Netbios calls (Name query to the remote host).
The netbios lookup is very undesired.

Is there a way to not perform the netbios query if the PTR record does not
exist?

Amy.

Nov 22 '05 #1
2 2274
"Amy L." <am**@paxemail.com> wrote:
IPHostEntry hostInfo = Dns.GetHostByAddress( hostIPAddress ) ;

If the PTR (i.e. the IP address to name resolution) does not exist my
program will start making Netbios calls (Name query to the remote host).

Is there a way to not perform the netbios query if the PTR record does not
exist?


Assuming the Netbios calls are a problem because of the long delay, I would
suggest an asynchronous approach. Then, if you don't receive a response
quickly enough, you can simply forget about it and move on, ignoring the
response that eventually arrives. The Dns class isn't able to do
asynchronous GetHostByAddress, but you can achieve a similar effect by
calling Dns.GetHostByAddress in a separate thread.

I'm not sure if this is what you were looking for, but I hope this helps.
--
Derrick Coetzee, Microsoft Speech Server developer
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included code samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Nov 22 '05 #2
Hi Amy,

I'll take you word on the netbios, to lazy to employer a packet sniffer to
validate this.

IPHostEntry hostInfo = Dns.GetHostByAddress is simple a wrapper method
around the winsock procedure gethostbyaddr. Short of getting you hands very
dirty and programming IP directly, you're stuck with this base
functionality.

Also GetHostByAddress can be very slow function to complete because it is
relying on a reverse DNS lookup, if it is performance that's bothering you
and you want a method call that will not block the current process read on.

Try using the asynchronous version of Dns.BeginResolve it will accept an IP
Address and return immediately. Internally it calls GetHostByAddress. This
way your application won't block while waiting for a response from
GetHostByAddress and you can go an do something else, ie; repaint the screen
if using winforms and/or display a progress bar. Eventually when
GetHostByAddress completes you program will be notified by a call back
method.

Please let me know if you require a Dns.BeginResolve code sample.

Regards

Ian

"Amy L." <am**@paxemail.com> wrote in message
news:uX****************@TK2MSFTNGP14.phx.gbl...
When I make the following call:

IPHostEntry hostInfo = Dns.GetHostByAddress( hostIPAddress ) ;

If the PTR (i.e. the IP address to name resolution) does not exist my
program will start making Netbios calls (Name query to the remote host).
The netbios lookup is very undesired.

Is there a way to not perform the netbios query if the PTR record does not
exist?

Amy.

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ruggierorizzi | last post by:
Hi everyone, i would like to know if there is a difference between gethostbyaddress method and $_SERVER. furthermore i hve a little problem using ip address resolution. Some ip address...
1
by: Rushikesh Joshi | last post by:
Hi Friends I am having some query. On a server two site hosted 1) magnamags.com 2) stardustindia.com Now when I am resolving the IP address for this both sites. I am getting...
1
by: Amy L. | last post by:
When I make the following call: IPHostEntry hostInfo = Dns.GetHostByAddress( hostIPAddress ) ; If the PTR (i.e. the IP address to name resolution) does not exist my program will start making...
1
by: huzz | last post by:
I wrote a method which takes an ip address and returns hostname as shown below. It works fine.. only problem i have is when the passed ip address is not found in the database the method throws this...
3
by: RZ | last post by:
Hi Folks, I wrote an app to scan our Packet Filter logs for certain IPs. It uses GetHostByAddress(). I used multi-threading to get around the 2 second hang. The remaining problem is that...
5
by: Sven | last post by:
Hi! I have a problem with System.Net.Dns.GetHostByAddress(ls_Request.UserHostAddress()).HostName Usually the call GetHostByAddress returns the correct hostname of the client, but sometimes...
1
by: Jed | last post by:
I have a class for logging information about user activity on a web site, but it suddenly became really slow. I was wondering what factors may have caused the slow down. Initially, I used the...
1
by: Asfar Sadewa | last post by:
Hello all, I have a web application written in C# that needs to track the machine name, ip, and the user name of the accessor. the application is hosted on a web server using SSL. i got the...
3
by: Steve Richter | last post by:
I am using Dns.GetHostByAddress and Dns.Resolve to successfully resolve and IP address to an IPEndPoint. IPEndPoint ep = null; IPAddress ipAddr = IPAddress.Parse(m_sRemoteHost); ep = new...
1
by: Nicopilami | last post by:
Hello, i would like to retrieve the hostname from IP adress, but according to microsoft (VS 2008 Express), DNS.Resolve and GetHostByAddress methods seem to be deprecated, and all i found on google...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...
0
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...
0
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
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,...

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.