Neat trick most people don't realize

| | Comments (9)

You can use the RB DNS resolver for resolving things other than IP address and DNS addresses. For example, it'll resolve NetBIOS addresses as well.

Let's say I've got two machines on the network with the "names" MiniCompy and WinRocks. And by names, I mean, this is the "network" name for the machine -- it's the name that shows up in when browsing samba shares, for example.

I can simply tell my socket to connect to one of them, like this:
[rbcode]
TCPSocket1.Port = 8080
TCPSocket1.Address = "MiniCompy"
TCPSocket1.Connect
[/rbcode]
The DNS resolver will figure out that this is a NetBIOS address and do the appropriate resolution for it without you having to go thru the trouble.

Neat, eh?

9 Comments

does RB do it? or does your OS do it?

The OS, I certainly didn't write any netbui code. ;-)

Hm, is this Win32 only? or does it also detect OS X (and Linux) by hostnames?

-- SirG3

That is neat. Too bad it's not in the docs. :^) Wonder when the documentation position is going to be filled...

@SirG3 -- looks to be Win32-only. I could have sworn the Mac did it as well, but I guess not.

@Seth -- I didn't even know this trick until I went and tried it myself. I thought I'd have to use Win32 APIs to resolve the NetBIOS name. :-P

Yikes, I would hope this would be common knowledge for anybody writing a network application... that's pretty basic stuff. It also resolves the entries in your Hosts file, BTW. ;)

LoL, NetBIOS isn't exactly well-used technology for programmers, just look at the APIs you need to use! But you're right, it was silly of me not to notice this earlier.

And I know about the hosts file. Smartass. :-P

Well, programmers, IMO, shouldn't be programming network applications unless they've spent some time "under the hood" of a network... or at least taken a 100-level networking class in college. Otherwise you end up with crap like, hmm, the Pharmacy system we have here that inexplicably uses UDP packets instead of TCP, and therefore can't run over our wireless network. ("We'll have that fixed in November... 2004!" Hah, right!)

Anyway, as a network administrator myself, I'm constantly frustrated by applications that don't work on a network. Apps that require admin to function, that don't keep settings in the right place, etc.

I agree.

And FWIW, it's not my fault -- the OS doco doesn't state what it resolves.

;-)

Leave a comment