The information in this article applies to:
SUMMARY
If you are writing Windows Sockets applications that use the AF_NETBIOS
protocol family, you need to address the six issues discussed in this
article.
MORE INFORMATIONIssues to Address When Writing Windows Sockets ApplicationsIssue 1:When you are creating an AF_NETBIOS socket, specify -1 times lana for the protocol option. The Windows NT WinSock library allows the programmer to create a socket that allows communication over a particular lana. The lana number is specified via the protocol option of the socket() function. To create an AF_NETBIOS socket, specify -1 times the lana for the protocol option of the socket() function. For example:
The lana numbers are basically indices to the list of transports supported
by the NetBIOS implementation. A given host has one unique lana number for
every installed transport that supports NetBIOS. For example, listed below
are some possible lana numbers for a typical Windows NT configuration:
In the case of a multi-homed host (a computer with multiple network
adapters), the number of unique lana numbers equals the number of network
transports that support NetBIOS times the number of network adapters. For
example, if the computer depicted above contained two network adapters, it
would have a total of 3 * 2 = 6 lana numbers.
Also, please note the WSNetBS.h header included with the Windows NT version 3.5 SDK erroneously defines the NBPROTO_NETBEUI symbol. You cannot use this symbol as a protocol option and you should ignore it. Issue 2: Use the snb_type values provided by the WSNETBS.H header for NetBIOS name registration and de-registration. When filling out a sockaddr_nb structure, you must specify the appropriate value for the snb_type field. This field is used during the bind() operation to handle NetBIOS name registration. The WSNetBS.h header defines several values for this field. However, only the following two values are currently implemented:
Issue 3: Use the supported socket types of SOCK_DGRAM and SOCK_SEQPACKET. Due to the nature of NetBIOS connection services, SOCK_STREAM is not supported. Issue 4: Choose a NetBIOS port that does not conflict with your network client software. The NetBIOS port is an eight-bit value stored in the last position of the snb_name that is used by various network services to differentiate various type of NetBIOS names. When you register NetBIOS names, choose port values that do not cause conflicts with existing network services. This is of particular importance if you are registering a NetBIOS name that duplicates a user name or a machine name on the network. The following lists the reserved port values:
Issue 5:
Applications should use all available lana numbers when initiating communication. Because the NetBIOS interface can take advantage of multiple transport protocols, it is important to use all lanas when initiating communication. Server applications should accept connections on sockets for each lana number, and client applications should attempt to connect on every available lana. In a similar fashion, data gram broadcasts should be sent from sockets created from each lana. The following diagram depicts the lana mappings for two machines. In order for a client application running on Machine A to communicate with a server application on Host B, the client application must create a socket on lana 3, and the server must create a socket on lana 1. Because the client and the server cannot know in advance which single lana to use, they must create sockets for all lanas.
This diagram illustrates several other important points about lanas. First,
a transport that has a certain lana number on one host does not necessarily
have the same lana number on other machines. Second, lana numbers do not
have to be sequential.
You can use the EnumProtocols() function to enumerate valid lana numbers. The following sample code demonstrates this type of functionality: Sample Code
Issue 6:
Performance: Use AF_NETBIOS for communication with down-level clients. On Windows NT, NetBIOS is a high-level emulated interface. Consequently, applications that use the WinSock() function over NetBIOS obtain lower throughput than applications that use WinSock() over a native transport such as IPX/SPX or TCP/IP. However, due to the simplicity of the WinSock interface, it is a desirable interface for writing new 32-bit applications that communicate with NetBIOS applications running on down-level clients like Windows for Workgroups or Novell Netware. Additional query words:
Keywords : kbnetwork kbAPI kbNetBIOS kbNTOS350 kbSDKPlatform kbWinsock kbGrpNet |
Last Reviewed: October 15, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |