DNS.GetHostByAddress Question

  • Thread starter Thread starter Amy L.
  • Start date Start date
A

Amy L.

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.
 
Amy L. said:
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.
 
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
 
Back
Top