Поделиться через


getnameinfo() WILL use NetBIOS for name resolution

Jeff here again from the Windows SDK team.

A customer pointed out an inconsistency in some MSDN documentation and I wanted to mention it here while the documentation bug works its way through editing.

According to the documentation for gethostbyaddr(), getnameinfo() will not use NetBIOS to do name resolution. This is incorrect. The following paragraph is wrong:

Although gethostbyaddr() no longer recommended for use as of Windows Sockets 2 and the getnameinfo() function should be used, gethostbyaddr() is capable of returning a NetBIOS name;
getnameinfo() is not. Developers requiring NetBIOS name resolution may need to use gethostbyaddr() until their applications are completely independent of NetBIOS names.

The TechNet page for Network Application Interfaces has this table:

The gethostbyaddr() or getnameinfo() functions use the following (default) address look-up sequence:

1. Check the Hosts file for a matching address entry.
2. If a DNS server is configured, query it.
3. Send a NetBIOS Adapter Status Request to the IP address being queried. If it
responds with a list of NetBIOS names registered for the adapter, parse it for
the computer name.

A network trace shows the NBNS request:

10.53.4.255         10.53.18.120       NBNS    92           Name query NBSTAT
*<00><00><00><00><00><00><00><00><00><00><00><00><00><00><00>

 

/Jeff

Follow us on Twitter, www.twitter.com/WindowsSDK.