Real-time AC system based on TCPIP protocol

zhaozj2021-02-08  233

Real-time AC system based on TCP / IP protocol

Zhao Yong Qin Hong Sheng Zhang Weidong Lin Shaofan

Summary: Explain the soft, hardware environment, and technical points of the development of "chemical expert real-time communication systems", introduce the case of developing a Windows Sockets communication program with Visual C in a Windows 9X / NT environment, showing three-dimensional molecules in real time. Keywords: chemistry, socket, sockets, network communication diagram number: TP 393

With computer networks in our country, especially in colleges and universities, it has become an important tool for the majority of scientists to communicate and obtain information. The Internet has opened a channel for real-time communication. This article describes the "chemical expert real-time communication system" based on TCP / IP protocol based on the established chemical information website Cheminf, and strives to meet the needs of chemists.

1 Develop the soft and hardware environment of the Winows Sockets network communication program

1.1 hardware environment

Using the "Chemical Expert Real Time AC System", you need a computer that has been accessed into the Internet (dial-up access mode is not supported because the dialing method is dynamic IP technology). In order to display the real color three-dimensional molecules, you need to support the display mode of 16-bit reinforcing colors or more.

1.2 operating system and development environment

Windows 9x / NT supports Windows Sockets API, in the following introductions, we will be in an example in the development of the Windows 9X environment. The programming language uses visualization, object-oriented Microsoft Visual C 5.0. The Microsoft Base class (MFC, ie Microsoft Foundation Class) library in Visual C 5.0 is a series of C classes, which encapsulates a variety of functions to write applications for the Microsoft Windows operating system series. In terms of socket, Visual C 5.0 has a series of encapsulation for the original Windows Sockets library function, which has created CSocket, CSocketFile, etc., which encapsulates various functions about sockets.

1.3 Communication Agreement

We use the TCP / IP protocol. Windows 9x / NT has an agreement. However, the developed network communication applications cannot be deal directly with the TCP / IP core, but to deal with the network application programming interface Windows Sockets API. Windows Sockets API can communicate directly with the TCP / IP core. TCP / IP core protocols together with network physical media (such as NIC) are all available in network applications. The reason for choosing TCP is because it is a connection-based protocol. When the file is transmitted, the connection is established, ensuring the correctness of the file transfer; UDP is a connectionless protocol, which is not connected Will make sure the files of the transfer end can be transmitted correctly to the receiving end, so we do not use the UDP protocol. Of course, the UDP protocol is more efficient when making network broadcasts.

Application of 2 Socket Programming Model in Chemical Expert Real Time AC System

Network communication typically refers to two hosts or two processes, passing the data between them over the network, which can be understood as a network of a network (SESSION). Each end of the network dialog is the endpoint of network communication, namely the minimum unit of network communication entities. When using the Socket interface to program network communication, Socket is an abstract representation of the endpoint during the network communication. We use the customer / server model, the specific process is shown below:

3 small knot

Implementing the data communication of the Windows Sockets application, you must add TCP / IP protocols in the network configuration item in the Windows 9x / NT Control Panel, and give the corresponding IP address, these IP addresses are in the local area network, Can't be repeated, usually Class C addresses.

Server Client (Client) 1, Constructor Solder SER_S11, Constructed Solder Cli_S2, Create This Socket 2. Create Nuclear Socket SER_S1.CREATE (Port); CLI_S.CREATE (); In the country, Port is the communication port number 3 that is opened for the server, starts to listen to the connection 3, the client socket CLI_S issues a connection request to the server square sleeve SER_S1: CLI_S.Connect (addr, port); AddR is to connect the server square set address structure pointer, which can use IP addresses or machine names. The port number open, its value is consistent with the server side. 4, construct a new socket SER_S25, the server waits for accepting the client connection request 6 on Ser_s2, constructing a class CSocketFile object file4, constructing a class CSocketFile object file7, constructed class carchive object arin, arout for use The receipt of the data. 5. Table CARCHIVE object Arin, Auout, for use in the receipt of the data. 8. Use arin and arout to receive or send data 6, use arin and arout to send or collect data arout >> value; arout << Value; arout << value; arin >> value; where Value is the data transmitted , Including the bonding relationship between atomic locations, atomic types, and atoms, and the like. Among them, Value is the transmitted data, including a bonding relationship between atomic locations, atomic types, and atoms, and the like. 9. Destroy the object of CSocket, CsocketFile, Carchive, etc., destroy the objects of CSocket, CsocketFile, Carchive, etc. Creating Csocket, CsocketFile, CARCHIVE.

Using Visual C 5.0 for Windows Sockets application development, you need to pay attention to the following: (1) Server side and client applications must be initialized, such as port (port) default settings, etc. Since our "chemical expert real-time AC system" is a server and client and a complex (ie, the same information can be received and transmitted), the initialization process is more important. (2) The communication module should be written independently, and network communication is used as a module in the application, which is conducive to the weighing to other applications. (3) Try to avoid the simultaneous transmission of data from both parties, which may cause temporary blocking of data. At present, the system basically meets the needs of chemists exchanges, with strong application value, and can successfully implement real-time data transmission in the case of ensuring sufficient bandwidth of the network.

Author: Zhao Yong (Nankai University Center Laboratory Tianjin 300071) Qin Hongsheng (Nankai University Center Laboratory Tianjin 300071) Zhang Weidong (Nankai University Center Laboratory Tianjin 300071) Lin Shaofan (Nankai University Center Laboratory Tianjin 300071)

references

转载请注明原文地址:https://www.9cbs.com/read-1720.html

New Post(0)