473,396 Members | 1,767 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,396 software developers and data experts.

Name resolution in .Net - arrrrrggghhhh!

I have been having some serious problems with System.Net.Dns.Resolve.

The documentation states:

"The Resolve method queries a DNS server for the IP address associated
with a host name or IP address."

"When hostName is a DNS-style host name associated with multiple IP
addresses, only the first IP address that resolves to that host name is
returned."
Both these assertions appear to be incorrect.

The second assertion is quite clearly wrong. This method returns an
IPHostEntry instance, which has an AddressList property. This property
is an array of IPAddress instances. A quick test of this method reveals
that this list will conatin more than one item if the name resolves to
more than one IP address. Black mark number one, unless I have
misunderstood something.

Now to the first assertion. I have a box which has two network
adapters. One of these adapters is to a network with private
non-routable ip addresses and no routing/bridging is allowed between
the networks; the ip address of this NIC is 10.0.0.5. The private
network has no DNS server, and there are no host file entries for hosts
on this private network. The other network card connects to my main
subnet which has all the usual infrastructure such as DNS; the ip
address of this NIC is 192.168.0.2

My machine is called 'terminus'. Terminus has one single entry in the
DNS, which resolves to 192.168.0.2. A quick test with nslookup confirms
that this hostname has a single A record to point to this ip address.
Why then, when I call System.Net.Dns.Resolve ( "terminus" ) do I get
both IP addresses returned? If this method did what it said, I would
only get the 192.168 address returned. I even get them in a perverse,
reverse order where the 10.0.0.5 comes first. The fact of the matter is
that this method does *not* do what it says; or perhaps it does what it
says and then does sdome other things too.

Using

nbtstat -a terminus (on terminus itself)

reveals that the NetBIOS name cache contains both these IP addresses,
and in the order the Resolve call returns them.

I used a reflector to look into how the Resolve method works, and it
just appears to call the Windows Sockets function gethostbyname.
Firstly, this method is quite clearly marked as deprecated in the
documentation (so why is the .Net Framework 1.1 using it), and secondly
even the documentation for this call does not detail what it actually
does!

My feeling is that this function harks back to the NetBT days of NT
when it was preferable to try and resolve names via WINS or NetBIOS
broadcasts as well as IP. However, this is not what the documentation
says the function does, and there appears no way of actually doing a
basic DNS lookup with nothing else.

I have wasted a few days debugging problems that are directly
attributable to this and am pretty cross about it! Have I missed
something obvious, or is this function as misleading as it seems?

Is there a way of *only* doing a DNS lookup, akin to using nslookup?

Has anyone else had similar problems?

All help gratefully received,

Rob Levine
http://roblevine.blogspot.com

Nov 16 '05 #1
0 1279

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

Similar topics

0
by: Erik Bethke | last post by:
Hello All, I am trying to clean up some polish bugs with the Shanghai game I am working on and I am currently stuck on trying to get the right event for detecting when the user has changed the...
2
by: Vam | last post by:
my compiler doesn't compile the following: struct Base1 { virtual void F(){} }; struct Base2 { virtual void F(){}
44
by: Mohanasundaram | last post by:
int i = 10; int main() { int i = 20; return 0; } Hi All, I want to access the global variable i inside the main. Is there
2
by: Michael Evans | last post by:
First, we rely on a stable update rate so that our physics and dynamics calculations and integrations are based on a known interval and therefore are true-to-life. Second, the graphics positions...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
7
by: tim | last post by:
can someone tell me which function returns the screen resolution in java script?
5
by: Maxi | last post by:
I have a 30X16 cells table in my html page. Table height and width are set to 100%. I have set size of every cell inside the table to 24 pixel. When I open the html page in maximize state in...
7
by: Peter Oliphant | last post by:
In today's market, what's a good screen resolution that I can pretty much count on as being the minimum? This is kind of a 'fuzzy' question in that I'm interested in the biggest screen...
6
by: | last post by:
Hi, I need to get the the display monitor native resolution.I have tried SystemInformation.PrimaryMonitorSize. it is giving the exisiting resolution of the display monitor that is connected....
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
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.