Efficient multi-process multi-module communication system and method

By adopting a centralized socket server and message broadcasting mechanism in a multi-process system, combined with message ID and response mapping table, the link management complexity and data transmission efficiency of traditional multi-process multi-module communication systems are solved, and efficient Flexible and consistent communication architecture.

CN119211382APending Publication Date: 2024-12-27CHONGQING RUIMING INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411384144.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Traditional multi-process multi-module communication systems have shortcomings in link management complexity and data transmission efficiency, resulting in bloated system structure, waste of resources and inconsistent data transmission.

Method used

Adopting a centralized design, by creating a socket server in the central process and listening to preset communication ports, all processes establish connections to the central process, realizing message broadcast, reducing the number of links and reducing management complexity, and defining each business data at the same time A unique message ID, using a message response mapping table for data processing.

Benefits of technology

It simplifies inter-process communication link management, improves data transmission efficiency and consistency, reduces resource consumption and error risks, and makes the system more flexible and easy to scale.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119211382A_ABST
    Figure CN119211382A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of process communication, and discloses a high-efficiency multi-process multi-module communication system, which comprises a process definition module used for selecting one process from a plurality of processes as a central process, creating a socket server in the central process, monitoring a preset communication port, creating a socket client in all the processes, and monitoring the preset communication port; the socket client side of each process is connected to the socket server side of the central process through a preset communication port; a connection list is arranged in the process definition module, and the connection list is used for storing information of all socket clients connected with the socket server; the socket server side of the central process is used for receiving messages from the socket clients, traversing the connection list and broadcasting the messages to the processes of all the connected socket clients; the technical problems that in the prior art, timeliness of business data communication between processes is poor, and system resources are wasted are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of process communication, and in particular to an efficient multi-process multi-module communication system and method. Background Art

[0002] A multi-module multi-process communication system usually consists of multiple independent business modules, each of which runs in a separate process. These business modules use the inter-process communication mechanism to transmit data and work together to achieve the overall function of the system.

[0003] The traditional process communication method is to establish links for communication between all processes. When cross-process communication is required, business data is sent and received between each other through these links. In order to meet the communication between business modules within a single process, communication links are also established between multiple business modules, and business modules send and receive data through these links.

[0004] Since communication links are established between all processes, there are many links, which makes management very cumbersome. At the same time, a process usually contains multiple business modules, and communication links are established between each module, which makes the system structure bloated and significantly increases the complexity and difficulty of link management. When a process needs to send business data to multiple other processes, it must send data to each link in turn. The business modules in the process are also the same and must be sent multiple times in turn. This not only increases the complexity of the operation, but also easily leads to omissions and errors in data transmission.

[0005] In order to overcome the shortcomings of traditional process communication methods, the existing technology has made corresponding improvements. The existing technology sets up a third-party medium between multiple processes and multiple modules in a single process, so that the communication between processes or business modules is realized through the third-party medium. However, since the business modules of all processes need to access the same third-party medium, in order to ensure the integrity of the business data entered or read by the third-party medium and prevent data conflicts and inconsistencies, the access operation must be locked and mutually exclusive, so that only one business module or process can access the third-party medium at the same time. When the system is large in scale and the number of processes and business modules is large, the third-party medium that can only respond to the needs of one object at a time will greatly affect the transmission efficiency of business data.

[0006] At the same time, in order to ensure the timeliness of business data communication, the business modules of all processes need to detect in real time whether business data has been written to the third-party media. This not only increases the resource consumption of the system, but also increases the complexity of the logic implementation. Summary of the invention

[0007] The present invention aims to provide an efficient multi-process multi-module communication system and method to solve the technical problems of poor timeliness and waste of system resources in the prior art of business data communication between processes.

[0008] To achieve the above object, the present invention adopts the following technical solution: an efficient multi-process multi-module communication system, characterized in that it includes:

[0009] The process definition module is used to select a process from multiple processes as the central process, create a socket server in the central process, and listen to the preset communication port, create a socket client in all processes, and make the socket clients of each process connected to the socket server of the central process through the preset communication port;

[0010] A connection list is set in the process definition module, which is used to store information of all socket clients connected to the socket server; the socket server of the central process is used to receive messages from the socket client, traverse the connection list, and broadcast the message to all connected socket client processes.

[0011] The principles and advantages of this solution are: in actual application, the socket server is used in the central process to process all the messages of the socket clients of itself and other processes transmitted through the link; this centralized design greatly simplifies the management of communication links between processes, because all processes only need to establish a single connection with the central process, rather than establishing complex mesh connections with each other; the server sends the received messages to all clients in the list in the form of broadcast, realizing one-to-many efficient communication. At the same time, each client process does not need to apply to the server in real time. The clients of all processes only need to passively receive messages from the central process, without the need to detect in real time whether there is new data in the third-party media, thus greatly reducing the resource consumption of the system;

[0012] Compared with the traditional method, the present invention greatly reduces the number of communication links between processes and modules through centralized design, making link management simpler and more efficient. Each process only needs to maintain a connection to the central process, which greatly reduces the complexity and management difficulty of the system; the message broadcast mechanism enables data to be sent to all target processes at once, avoiding the tedious process of sending data to each process in turn in the traditional method. This not only reduces the number of data transmissions, but also reduces the risk of omissions and errors in data transmission;

[0013] The centralized communication architecture and message broadcast mechanism help ensure that the data received by all processes is consistent, thus avoiding data conflicts and inconsistencies. As the system scales up, new processes or modules only need to establish a connection with the central process to participate in the communication without modifying the communication logic of the existing process. This design makes the system more flexible, easy to expand and maintain.

[0014] Preferably, as an improvement, it also includes:

[0015] The business data definition module is used to define a unique message ID for business data according to the business type and create a globally unique message ID table, which is used to store the message IDs of all business data; the socket client of the process sends a message packet containing the message ID and business data to the socket server of the central process;

[0016] The business data corresponding module is used to create a message response mapping table. The message response mapping table is used to store the correspondence between each message ID and the callback function. The callback function is used to pass the corresponding business data to the specified business module; when receiving the message packet from the central process socket server, parse and obtain the message ID and business data, map the message ID to the message response mapping table, and obtain the callback function.

[0017] The beneficial effects of this improvement are as follows: by defining a message ID, different business data can be distinguished, which is convenient for subsequent forwarding; the globally unique message ID table is globally accessible, ensuring the uniqueness and traceability of the message ID; the callback function defines how to process the business data when a specific message ID is received, and passes it to the specified business module, searches for the corresponding callback function in the message response mapping table through the message ID, and executes the callback function to process the business data;

[0018] By defining a unique message ID for each business data and managing it globally, it can be ensured that there will be no data confusion or misprocessing during the communication process, which greatly improves the accuracy and reliability of data processing; business data is only transmitted to business modules with requirements, reducing unnecessary resource consumption; the solution reduces coupling through callback functions and message ID mapping, improving the maintainability of the system.

[0019] Preferably, as an improvement, the central process is a key process that is automatically loaded and run when the system starts.

[0020] The beneficial effect of this improvement is that once other processes or modules start running, they can immediately establish a connection with the central process without waiting for the initialization process of the communication system; as long as the system is in normal operation, the central process will be able to continue to run stably, and even if some non-fatal errors or restarts occur during the system operation, the central process can be quickly restored, thereby ensuring the stability of the entire communication system.

[0021] Preferably, as an improvement, after the message ID is mapped to the message response mapping table, what is obtained is a callback function list including multiple callback functions.

[0022] The beneficial effects of this improvement are: since the callback function exists in the form of a list, the system can dynamically add new callback functions to the list at runtime; different business logics are encapsulated in different callback functions and mapped through message IDs, which helps to reduce the coupling between different business modules; all callback functions related to a specific message ID are stored in a list, which helps to achieve centralized management of these callback functions; each callback function in the callback function list is called in turn and processed serially.

[0023] An efficient multi-process multi-module communication method for implementing a multi-process multi-module communication system comprises the following steps:

[0024] S1. Among multiple processes, a key process is selected as a central process. When the central process is started, a socket server is created and bound to a preset communication port, so that the socket server monitors the preset communication port in real time to establish a link connection with the client.

[0025] S2. When each process starts, it creates a socket client and tries to connect to the preset communication port of the socket server of the central process. The central process creates a connection list for storing the information of the connected socket clients.

[0026] S3. When a process needs to send business data, the process sends the message packet to the central process through the socket connection;

[0027] S4. The central process receives the client message packet transmitted by the link, and the socket server of the central process traverses the connection list and broadcasts the message packet to all connected socket client processes.

[0028] The beneficial effects of this improvement are: by selecting a key process as the central process, centralized management and control of communications are achieved; the central process server is responsible for listening to the preset communication port to establish a link connection with the client, receiving message packets transmitted by the link, and broadcasting messages to all connected client processes. This centralized architecture simplifies the communication process, reduces the complexity and error rate of communication; the central process listens to the preset communication port in real time to ensure that it can instantly establish a connection and receive message packets from any client process, ensuring the timeliness and response speed of communication; the central process server broadcasts the received message packets to all connected client processes to ensure that each process can obtain the latest business data in a timely manner; this broadcast mechanism improves the reliability and consistency of communication;

[0029] Each process creates a socket client when it starts and tries to connect to the socket server of the central process. This dynamic connection mechanism enables the system to flexibly add or delete processes without modifying the configuration of the central process. Message broadcasting through the central process reduces the number of message transmissions and redundant data in the network, thereby reducing network overhead and latency.

[0030] Preferably, as an improvement, the steps between S2 and S3 are further included: assigning unique message IDs to business data according to the business data type, and constructing a global unique message ID table, each process creating a message response mapping table according to the business module requirements within the process, the message response mapping table being used to store the mapping relationship between the message ID of each business data and the callback function of each business module;

[0031] In S3, the process that needs to send business data constructs a message packet including a message ID and business data.

[0032] The beneficial effects of this improvement are: with the unique message ID, the recipient can accurately identify and process the corresponding business data according to the message ID; when the central process broadcasts the message package, the recipient process can quickly locate the corresponding callback function and execute the corresponding processing logic, thereby improving the efficiency of message processing.

[0033] Preferably, as an improvement, the method further comprises the steps of:

[0034] S5. The process of the connected socket client receives and parses the message packet, obtains the message ID and business data, maps the message ID to the message response mapping table, and obtains the corresponding callback function list; traverses the callback function list, and calls each callback function in turn to send the business data to the specified business module.

[0035] The beneficial effect of this improvement is that in some complex business scenarios, a message may need to be processed by multiple business modules. By mapping the message ID to a list containing multiple callback functions, the system can easily support this multi-business module collaboration requirement. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 It is a schematic structural diagram of an embodiment of the present invention.

[0037] Figure 2 It is a schematic diagram of the structure of the message response mapping table according to an embodiment of the present invention.

[0038] Figure 3 Schematic diagram of inter-process communication according to an embodiment of the present invention.

[0039] Figure 4 The figure is a schematic diagram of the communication between modules in a single process according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] The following is further described in detail through specific implementation methods:

[0041] Example

[0042] Basically as attached Figure 1 As shown, an efficient multi-process multi-module communication system and method include an efficient multi-process multi-module communication system and an efficient multi-process multi-module communication method for implementing the multi-process multi-module communication system.

[0043] An efficient multi-process and multi-module communication system includes a process definition module, a business data definition module and a business data corresponding module.

[0044] The process definition module is used to select a process from multiple processes as the central process; the central process is a process that is automatically loaded and run when the system starts, that is, a system core process or a system key process, for example, in the Windows system: the session management subsystem (smss.exe), which is responsible for initializing system variables and starting user sessions; the client / server runtime subsystem (csrss.exe), which manages Windows graphics-related tasks; the local security authentication service (lsass.exe), which is used to process security policies and login verification; the service and controller application (services.exe), which is used to manage starting and stopping services; the general host process (svchost.exe) of services running from dynamic link libraries (DLLs), etc.

[0045] The process definition module creates a socket server in the central process and listens to the preset communication port. The process definition module creates a socket client in all processes and connects the socket clients of each process to the socket server of the central process.

[0046] The central process maintains a connection list, which stores all socket clients connected to the socket server. When the central process receives business data from any socket client, the socket server of the central process will distribute the business data to all connected clients in the connection list in the form of broadcast. The connected clients include the socket client of the central process and the socket client of the process sending data.

[0047] The business data definition module is used to define a unique message ID for business data according to the business type and create a globally unique message ID table, which stores the message IDs of all business data. The message ID is pre-defined during system design to ensure the uniqueness of each message ID. The socket client of the process sends a message packet containing the message ID and business data to the socket server of the central process.

[0048] Business data corresponding module, used to create message response mapping table, as shown in the attached Figure 2 As shown, the message response mapping table stores the correspondence between each message ID and each callback function, and the callback function is used to pass the corresponding business data to the specified business module.

[0049] The business data corresponding module maps the received message ID to the corresponding callback function list, so that the business data of the message ID is passed to the specified business module by the corresponding callback functions. According to the needs of the business modules in the process, each process maintains a message response mapping table. A business data in a single process may be required by multiple business modules. When the message ID mapping is searched, a callback function list containing multiple callback functions may be returned.

[0050] For example, use C++ syntax to define a message response mapping table:

[0051] map <xint32_t,vector<CallbackFun_t> >

[0052] Meaning:

[0053] xint32_t: message ID

[0054] CallbackFun_t: callback function information, defined as follows:

[0055] typedef struct

[0056] {

[0057] null_class*pClass; / / this pointer of the class object where the callback function is located

[0058] CALLBACK_FUN pCallback; / / callback function address

[0059] }CallbackFun_t;

[0060] typedef void(null_class::*CALLBACK_FUN)(const xbyte_t*,xuint32_t);

[0061] vector<CallbackFun_t> : Callback function list. In a single process, there may be multiple business modules that need to obtain business data for a specified message ID.

[0062] An efficient multi-process multi-module communication method includes the following steps:

[0063] S1. Among multiple processes, a key process is selected as a central process. When the central process is started, a socket server is created and bound to a preset communication port, so that the socket server monitors the preset communication port in real time to establish a link connection with the client.

[0064] S2. When each process starts, it creates a socket client and tries to connect to the preset communication port of the socket server of the central process. The central process creates a connection list for storing the information of the connected socket clients.

[0065] S3. Assign unique message IDs to business data according to business data types, and build a globally unique message ID table. Each process creates a message response mapping table according to the business module requirements within the process. The message response mapping table is used to store the mapping relationship between the message ID of each business data and the callback function of each business module;

[0066] S4. When a process needs to send business data, the process constructs a message packet containing the message ID and business data, and sends the message packet to the central process through the socket connection;

[0067] S5. The central process receives the client message packet transmitted by the link, and the socket server of the central process traverses the connection list and broadcasts the message packet to all connected socket client processes;

[0068] S6. The process of the connected socket client receives and parses the message packet, obtains the message ID and business data, maps the message ID to the message response mapping table, and obtains the corresponding callback function list; traverses the callback function list, and calls each callback function in turn to send the business data to the specified business module.

[0069] In S5, the preset communication port can simultaneously receive message packets sent by multiple clients via the link. When the server broadcasts the message packet to all connected client processes, the client objects broadcast by the server include the client itself that sent the message packet to the server.

[0070] To more clearly illustrate how to achieve communication between modules and processes, here is an example of the process:

[0071] As attached Figure 3 As shown, the system includes four processes, among which a key process is defined as the central process. To facilitate subsequent description, each process is named, and the four processes are respectively process A, process B, process C and the central process.

[0072] The client is built in process A, process B, process C and the central process, and the server is only built in the central process. In this case, the central process has both the client and the server. The link connection between the client and the server is defined using a preset communication port, so that the clients of process A, process B, process C and the central process all establish links to the preset communication port to connect to the server of the central process.

[0073] If at this time, a business module in process A needs to send business data, a message packet containing the message ID and business data is constructed, and the client of process A sends the message packet containing the business data to the server of the central process through the link. The server of the central process promptly receives the message packet from process A on the link and sends the message packet to all linked client processes. It should be noted that the client of process A and the client of the central process as the sender will also receive the message packet from the server of the central process.

[0074] The clients of process A, process B, process C and the central process receive the message packets containing the business data, parse the message packets, and obtain the message ID and the business data.

[0075] As attached Figure 4 As shown, only one process client processes a message packet as an example here, and the other process clients process the message packets in the same way, which will not be described in detail here.

[0076] The B process contains four independently running business modules, namely the first module, the second module, the third module and the fourth module. After receiving the message packet from the central process server, the B process parses and obtains the message ID and business data, maps the message ID to the message response mapping table, and obtains the corresponding callback function list. The callback function list corresponding to this message ID is the callback function of the first module and the callback function of the second module.

[0077] The first module callback function and the second module callback function are called to forward the business data only to the first module and the second module. In the B process, the third module and the fourth module have no need to obtain the business data.

[0078] The above is only an embodiment of the present invention, and the common knowledge such as the known specific technical solutions and / or characteristics in the solution is not described in detail here. It should be pointed out that for those skilled in the art, without departing from the technical solution of the present invention, several modifications and improvements can be made, which should also be regarded as the protection scope of the present invention, and these will not affect the effect of the implementation of the present invention and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.

Claims

1. An efficient multi-process multi-module communication system, characterized in that: include: The process definition module is used to select a process from multiple processes as the central process, create a socket server in the central process, and listen to the preset communication port, create a socket client in all processes, and make the socket clients of each process connected to the socket server of the central process through the preset communication port; A connection list is set in the process definition module, which is used to store information of all socket clients connected to the socket server; the socket server of the central process is used to receive messages from the socket client, traverse the connection list, and broadcast the message to all connected socket client processes.

2. An efficient multi-process multi-module communication system according to claim 1, characterized in that: Also includes: The business data definition module is used to define a unique message ID for business data according to the business type and create a globally unique message ID table, which is used to store the message IDs of all business data; the socket client of the process sends a message packet containing the message ID and business data to the socket server of the central process; The business data corresponding module is used to create a message response mapping table. The message response mapping table is used to store the correspondence between each message ID and the callback function. The callback function is used to pass the corresponding business data to the specified business module; when receiving the message packet from the central process socket server, parse and obtain the message ID and business data, map the message ID to the message response mapping table, and obtain the callback function.

3. An efficient multi-process multi-module communication system according to claim 2, characterized in that: The central process is a key process that is automatically loaded and run when the system starts.

4. The efficient multi-process multi-module communication system according to claim 3, characterized in that: After the message ID is mapped to the message response mapping table, what is obtained is a callback function list including multiple callback functions.

5. An efficient multi-process multi-module communication method for implementing the multi-process multi-module communication system according to any one of claims 1 to 4, characterized in that: The following steps are involved: S1. Among multiple processes, a key process is selected as a central process. When the central process is started, a socket server is created and bound to a preset communication port, so that the socket server monitors the preset communication port in real time to establish a link connection with the client. S2. When each process starts, it creates a socket client and tries to connect to the preset communication port of the socket server of the central process. The central process creates a connection list for storing the information of the connected socket clients. S3. When a process needs to send business data, the process sends the message packet to the central process through the socket connection; S4. The central process receives the client message packet transmitted by the link, and the socket server of the central process traverses the connection list and broadcasts the message packet to all connected socket client processes.

6. The efficient multi-process multi-module communication method according to claim 5, characterized in that: The steps between S2 and S3 also include: assigning unique message IDs to service data according to the service data type, and constructing a globally unique message ID table; each process creates a message response mapping table according to the service module requirements within the process; the message response mapping table is used to store the mapping relationship between the message ID of each service data and the callback function of each service module; In S3, the process that needs to send business data constructs a message packet including a message ID and business data.

7. An efficient multi-process multi-module communication method according to claim 6, characterized in that: Also includes the steps: S5. The process of the connected socket client receives and parses the message packet, obtains the message ID and business data, maps the message ID to the message response mapping table, and obtains the corresponding callback function list; traverses the callback function list, and calls each callback function in turn to send the business data to the specified business module.