NetBIOS also provides "Connected" service and "no connection" service. Connected service means it allows two clients to build a session between each other, or establish a "virtual loop". This session is actually a two-way communication data stream, and each party of the communication can send a message to the other party. Connected service guarantees between two endpoints, any data can be transmitted accurately. In this service, the server usually registers yourself to a known name. The client searches this name to establish communication with the server. When you take NetBIOS, the server process will add your name to the name table corresponding to its corresponding name for each LANA number that wants to create communication. For customers on other machines, a service name can be parsed into a machine name and then require a connection to the server process. You can see that some appropriate steps must be taken to build this virtual loop. Moreover, some additional overhead is also involved in the initial connection. "Connected" or "session" communication can ensure that communication has extremely high reliability, and the order of delivery of packets can also be guaranteed correctly. However, it is still a "message-based" service. That is, if a client has been connected to a "read" command, then the server will only return a packet in the stream - although the client provides a sufficiently large buffer, it can be Take a few packages!
In the "connection" or datagram service, the server does not register itself to a specific name, but only collects data by the client, then send it to the network, do not have to build any connection (ie, no connection) beforehand. For the destination address of the data, the client will define it to the NetBIOS name corresponding to the server corresponding process. This type of service does not provide any guarantee, but it can have better performance compared to the connection-to-connection service. If you use the datagram service, the overhead required to establish a connection is saved. For example, the client may send a thousand bytes of data to the server, but that the server is already aircraft as early as one or two days. Unless dependent on the response from the server, the client will never receive any error prompts.
Now we have understood some basic concepts of NetBIOS, and then discuss the NetBIOS settings, only one function:
Uchar NetBIOS (PNCB PNCB);
All function declarations, constants, and the like for NetBIOS are defined within the header file Nb30.h. If you want to connect the NetBIOS app, the only thing you need is the library NetApi32.lib. The most important feature of this function is the parameter of the PNCB, and she corresponds to a pointer to a network control block (NCB). In that NCB structure, all information needs to be used for performing a NetBIOS command. The definition of this structure is as follows:
Typedef struct _ncb
{UCHAR NCB_COMMAND;
Uchar NCB_RETCODE;
Uchar NCB_LSN;
Uchar NCB_NUM;
PuChar NCB_Buffer;
Word NCB_LENGTH;
Uchar ncb_callname [ncbnamesz];
Uchar ncb_name [ncbnamez];
Uchar ncb_rto;
Uchar ncb_sto;
Void (* NCB_POST) (Struct_ncb *);
Uchar NCB_LANA_NUM;
UCHAR NCB_CMD_CPLT;
Uchar NCB_RESERVE [10];
Handle NCB_EVENT;
} * Pncb.ncb
Before conducting any NetBIOS calls, don't fill in the structure within the beginning, and you should clear this NCB structure first.