473,322 Members | 1,473 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,322 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 2267
"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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.