Programming with NetBIOS in C++builder

Source: Internet
Author: User
Tags reset sessions

NetBIOS is the network basic input/output system, is an application to the program interface for data source and destination data exchange. That is, access to various services to support computer applications and device communications, with a clear and simple communication protocol, and a special sequence of commands must be used to invoke the NetBIOS service.

First, let's take a look at the basics of NetBIOS.

I. The basics of NetBIOS

1. At the network level, NetBIOS is between the presentation layer and the session layer, and is the high-level of the reference model. Therefore, the application of its interface program is largely isolated from the various activities at lower levels, in essence. It supports the IEEE802.2 logical link Control (LLC) protocol. Now, NetBIOS is rapidly becoming a widely used data communication platform in different operating system environments, including PC Dos,os/2,unix and Windows.

2. The presence of NetBIOS was in the August 1984 IBM PC network adapter, which was designed by Sytek company for IBM. It uses broadband coaxial cable, provides 2MB data transmission burst per second, uses the popular industrial standard CSMA/CD (Multiple Access carrier interception/carrier detection) as the Access Protocol, which first appeared in IEEE 802.3 Ethernet standards.

3. NetBIOS Application Services: NetBIOS provides four kinds of application services: named support, datagram support, session support, and generic commands.

(1). Name support: Each NetBIOS network product adapter uses one or more network names to identify itself on the network to differentiate it from other network adapters. The network name is made up of 16 characters.

(2). Datagram Support: When an adapter is activated on the network, applications on the computer can use NetBIOS to communicate with other applications that reside on the same or different computers. The application communication between them can be performed using datagrams.

The datagram is a short message, its length varies with the NetBIOS implementation method, and does not guarantee the correct transmission of the data. Also does not receive instructions from the receiver, such as if it exists, does not power on or does not receive datagrams, so that when a network fails, the datagram emitted may not be received by any computer.

There are two kinds of datagrams: Broadcast type and directional type. A broadcast type is a datagram that is completely insensitive to the recipient, can use the NetBIOS Send Broadcast datagram command to send data, and the receiver can invoke the NetBIOS receive Broadcaset Datagram command to receive data. A directed type is the group name of the specified datagram recipient, and either party can call the NetBIOS Send datagram command to send data, and the receiver can invoke the NetBIOS receive datagram command to receive the sent data.

(3). Session Support: The second form of communication in NetBIOS applications is session communication, which supports the ability to create a reliable two-way data communication connection between two applications and maintain a long period of time. This connection is sometimes called a virtual circuit. Applications that communicate with each other can reside on the same computer (a local session) or reside on a different computer (a remote session).

The advantages of session communication over datagram communication are: For each sent message, you can know each other to receive the preparation before sending, and datagram communication only provides the sending status of information.

You can use the NetBIOS listen command to create a session, and the Listen command references a name in the NetBIOS command table. The other end causes the NetBIOS call command to use the name in its NetBIOS name table, which must match the name of the application on the other end, so that the names on both sides match the two application creation sessions, in the Listen command and call Once the command is done, the session is established. Note that the Listen command is invoked first, and then the call command is called, and this order cannot be reversed.

After the session is created, each client receives an indication that a session has been created and gets a byte unsigned return value that represents the union between the session and the adapter. After a session is created, each client can invoke the NetBIOS send and receive commands to transmit and receive numbers.

(4). Generic command: The generic command for NetBIOS provides five NetBIOS services: RESET (Reset adapter), Adapter status (display adapter status), Cancel and Unlink (undo and Disconnect Commands), find Name ( Match name) and trace (Trace command).

1). The Reset command forces the adapter into the initialization state, terminates all sessions, and deletes all names except the permanent section name in the NetBIOS naming table.

2). The Adapter Status command is used to query the NetBIOS adapters for information about the operation, such as discovering the number of LAN errors and the adapter NetBIOS naming table, to know whether the remote computer and adapter are either suspended or only the computer is suspended. This is a good way to implement a query on the state of a remote adapter.

3). The Cancel and unlink:cancel command is a command that causes the application to end before it has finished executing. The unlink command is a PC network LAN adapter that allows the RPL boot to be opened from the RPL server, which is only valid for the basic adapter, typically returning a value of 0, indicating that the request was successful. 4). The Find name command is used to locate an adapter that is specified by the search name command that can be answered at the same time when multiple adapters share a group name, but only one answer will be returned to the application that made the request.

5). The trace command activates all commands that are sent to the NetBIOS interface for the basic purpose of providing support for the diagnostics.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.