473,783 Members | 2,286 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1295

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

Similar topics

0
2734
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 desktop resolution. I have tried trapping the following events: 1) SDL_ACTIVEEVENT 2) SDL_VIDEOEXPOSE
2
2221
by: Vam | last post by:
my compiler doesn't compile the following: struct Base1 { virtual void F(){} }; struct Base2 { virtual void F(){}
44
2038
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
733
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 in our image generators are updated by this dynamics application, and we need to update them at the rate they are being refreshed so that we don't get any stutter from frames being used twice or having to be thrown out. Without microsecond...
20
7012
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 = document.getElementById('hometab'); Has anyone ever seen anything like this before, or am I dreaming?
7
8111
by: tim | last post by:
can someone tell me which function returns the screen resolution in java script?
5
6208
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 either resolution 800 X 600 or 1152 X 864 it takes up the entire explorer size. In screen resolution 800 X 600, if I insert a pictures of 24 X 24 pixel in the cells it takes up the entire cell size (ideally it should as the cell size is also 24 X...
7
1382
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 resolution that I can be pretty sure most people who buy a computer today (within the last year or two) will have a graphic card that supports it. For example, is 1024 x 768 x 32bits pretty much supported on most PC computers today?
6
5312
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. Please help me out to find the way to get the native resolution of the monitor that is connected -BMK
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9946
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2877
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.