Inter-process communication method, device, electronic device and storage medium
By generating and sending temporary pipeline names on the server side and sending temporary pipeline names through the main named pipeline, the client creates temporary pipelines, solving the problems of named pipeline communication blocking and high resource utilization, and achieving efficient inter-process communication.
Patent Information
- Application Number
- CN202211205100.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-28
- Publication Date
- 2025-05-16
- Estimated Expiration
- 2042-09-28
AI Technical Summary
The half-duplex communication characteristics of named pipes lead to communication blocking problems, affecting the client's data response and display, poor user experience, and the resident named pipes lead to high resource occupancy and waste of resources.
Receive the client's communication interface request through the pre-built main named pipe, generate a temporary pipeline name and send it to the client through the main named pipe. The client creates a temporary pipeline based on the temporary pipeline name, avoiding the creation of resident named pipes on the server and reducing resource usage.
It avoids communication blocking problems, reduces resource usage, and improves resource utilization and communication efficiency.
Smart Images

Figure CN115580581B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of communication technology, and in particular, to an inter-process communication method, device, electronic device, and storage medium. Background Art
[0002] Named pipes are a method of inter-process communication. Since named pipes are half-duplex communication (data can only flow in one direction at the same time), if a computer client process frequently sends communication interface requests to a server in a short period of time, and the server needs to reply the processed data to the client, the general named pipe communication method will cause serious congestion in the pipeline, similar to the synchronization effect. The client can only receive response results one by one, which affects the client's data response and display, and the user experience will also be very poor.
[0003] Although the method of using resident named pipes for communication can solve the blocking problem, it is easy to cause problems such as high resource usage and resource waste. Summary of the invention
[0004] The present application provides an inter-process communication method, device, electronic device and storage medium to solve all or part of the problems in the prior art.
[0005] In a first aspect, the present application provides an inter-process communication method, which is executed by a server and includes:
[0006] receiving at least one communication interface request sent by a client through a pre-built main named pipe;
[0007] Generate a first temporary pipe name corresponding to a first communication interface request, wherein the first communication interface request is any one of the at least one communication interface request;
[0008] Send all temporary pipe names to the client through the main named pipe, so that the client can create temporary pipes according to each temporary pipe name;
[0009] Acquire first service processing data corresponding to the first communication interface request according to the first communication interface request;
[0010] The first business processing data is sent to the client through a temporary pipe corresponding to the first temporary pipe name.
[0011] In this way, a temporary pipe name is generated according to the number of interface requests through the main named pipe and the temporary pipe name is sent to the client through the main named pipe, so that the client can create a corresponding temporary pipe according to the temporary pipe name and create it only when a request occurs, thereby avoiding communication blocking problems, reducing resource occupation, improving resource utilization, and improving communication efficiency.
[0012] In combination with the first aspect, in a first embodiment of the first aspect of the present invention, generating a first temporary pipe name corresponding to the first communication interface request specifically includes:
[0013] A first temporary pipe name corresponding to the first communication interface request is generated using a globally unique identifier algorithm.
[0014] In this way, a temporary pipe name is generated using a globally unique identifier algorithm, which can avoid unnecessary system problems caused by duplicate pipe names.
[0015] In combination with the first aspect or the first embodiment of the first aspect, in a second embodiment of the first aspect of the present invention, after sending the first service processing data to the client through the first temporary pipe corresponding to the first temporary pipe name, the method further includes:
[0016] An instruction to close the temporary pipe corresponding to the first temporary pipe name is sent to the client.
[0017] In this way, after the temporary pipe has transmitted the business data, an instruction to close the temporary pipe is sent to the client, so that the client can close the temporary pipe according to the instruction, and the resources occupied by the temporary pipe can be released after the business data transmission is completed, thereby further improving resource utilization.
[0018] In combination with the first aspect or the first embodiment of the first aspect, in a third embodiment of the first aspect of the present invention, before receiving at least one communication interface request sent by the client through the pre-built primary named pipe, the method further includes:
[0019] Create a primary named pipe based on the preset primary pipe name.
[0020] In this way, the server creates a main named pipe according to the main pipe name pre-agreed with the client, which is conducive to the client connecting to the main named pipe according to the main pipe name.
[0021] In a second aspect, the present application provides an inter-process communication method, which is executed by a client and includes:
[0022] Send at least one communication interface request to the server through a pre-built primary named pipe;
[0023] receiving a temporary pipe name corresponding to each of the at least one communication interface request sent by the server;
[0024] Creating a corresponding first temporary pipe according to the first temporary pipe name, wherein the first temporary pipe name is a temporary pipe name corresponding to the first communication interface request, and the first communication interface request is any communication interface request of the at least one communication interface request;
[0025] The first business processing data returned by the server is received through the first temporary pipeline, wherein the first business processing data is business processing data corresponding to the first communication interface request.
[0026] In this way, a communication interface request is sent through the main named pipe, and a temporary pipe is created according to the received temporary pipe name. The temporary pipe is created only when a request occurs, which avoids communication blocking problems, reduces resource usage, and improves resource utilization.
[0027] In combination with the second aspect, in a first embodiment of the second aspect of the present invention, after receiving the first business processing data returned by the server through the first temporary channel, the method further includes:
[0028] receiving, through the first temporary pipe, an instruction sent by the server to close the first temporary pipe;
[0029] Close the first temporary pipeline according to the instruction.
[0030] In this way, after the business processing data transmission is completed, the temporary pipeline is closed according to the close command, which can release the resources occupied by the temporary pipeline and further improve resource utilization.
[0031] In a third aspect, the present application provides an inter-process communication device, the device being a server, and the device comprising:
[0032] A receiving module, used for receiving at least one communication interface request sent by a client through a pre-built main named pipe;
[0033] A generating module, configured to generate a first temporary pipe name corresponding to a first communication interface request, wherein the first communication interface request is any one of the at least one communication interface request;
[0034] The sending module is used for sending all temporary pipe names to the client through the main named pipe, so that the client can create temporary pipes according to each temporary pipe name;
[0035] A processing module, configured to obtain first service processing data corresponding to the first communication interface request according to the first communication interface request;
[0036] The sending module is further used to send the first business processing data to the client through a temporary pipe corresponding to the first temporary pipe name.
[0037] Optionally, the device comprises:
[0038] The generating module is further used to generate a first temporary pipe name corresponding to the first communication interface request by adopting a globally unique identifier algorithm.
[0039] Optionally, the device comprises:
[0040] The sending module is further used to send an instruction to the client to close the temporary pipe corresponding to the first temporary pipe name.
[0041] Optionally, the device further comprises: a creation module;
[0042] A creation module is used to create a main named pipe according to a preset main pipe name.
[0043] In a fourth aspect, the present application provides an inter-process communication device, the device being a client, and the device comprising:
[0044] A sending module, used for sending at least one communication interface request to the server through a pre-built main named pipe;
[0045] A receiving module, used for receiving a temporary pipe name corresponding to each communication interface request in at least one communication interface request sent by the server;
[0046] A creation module, configured to create a corresponding first temporary pipe according to a first temporary pipe name, wherein the first temporary pipe name is a temporary pipe name corresponding to a first communication interface request, and the first communication interface request is any communication interface request of at least one communication interface request;
[0047] The receiving module is further used to receive first business processing data returned by the server through the first temporary pipeline, wherein the first business processing data is business processing data corresponding to the first communication interface request.
[0048] Optionally, the device further comprises: a closing module;
[0049] The receiving module is further used to receive, through the first temporary pipeline, an instruction sent by the server to close the first temporary pipeline;
[0050] The closing module is used to close the first temporary pipeline according to the instruction.
[0051] In a fifth aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0052] Memory, used to store computer programs;
[0053] The processor is used to execute the program stored in the memory, and when the electronic device includes a server, implement the steps of the inter-process communication method of any embodiment of the first aspect, or when the electronic device includes a client, implement the steps of the inter-process communication method of any embodiment of the second aspect.
[0054] In a sixth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the inter-process communication method as in any embodiment of the first aspect are implemented, or the steps of the inter-process communication method as in any embodiment of the second aspect are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 A schematic diagram of the process interaction of an inter-process communication method provided by the present invention;
[0056] Figure 2 A schematic diagram of a process flow of a communication method between processes executed by a server provided in an embodiment of the present invention;
[0057] Figure 3 A schematic diagram of a process flow of an inter-process communication method executed by a client provided in an embodiment of the present invention;
[0058] Figure 4 A schematic diagram of an interaction flow of another inter-process communication method provided by an embodiment of the present invention;
[0059] Figure 5 A schematic diagram of the structure of an inter-process communication device on a server provided by an embodiment of the present invention;
[0060] Figure 6 A schematic diagram of the structure of a communication device between client processes provided by an embodiment of the present invention;
[0061] Figure 7 A schematic diagram of the structure of an electronic device is provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0063] To facilitate understanding of the embodiments of the present invention, specific embodiments will be further explained below in conjunction with the accompanying drawings. The embodiments do not constitute a limitation on the embodiments of the present invention.
[0064] In view of the technical problems mentioned in the background technology, in order to solve the communication blocking problem caused by the half-duplex communication characteristics of the named pipe, a method of creating multiple resident named pipes is generally used to solve the blocking problem. Figure 1As shown, when the server starts, according to the number of inter-process communication (IPC) interface requests agreed with the client, a corresponding number of resident named pipes are created: named pipe 1 to named pipe N. The communication interface and the named pipe have a one-to-one correspondence. When the client starts, it connects to the resident named pipes created by the server: named pipe 1 to named pipe N. The client calls each communication interface: IPC interface 1 to IPC interface N through each resident named pipe. The server receives data from the corresponding communication interface through each resident named pipe and processes the corresponding business. After the business processing is completed, the server sends the processed business data: business data 1 to business data N to the client through the corresponding resident named pipe. The client reads the corresponding business data through the corresponding resident named pipe, processes and displays the relevant data. When the server process exits, each resident named pipe is closed.
[0065] This method can solve the communication congestion problem when the communication interface requests a large number of concurrent requests, but it will cause other problems. For example, if the client adds a new communication interface, the server needs to add a new named pipe simultaneously, which is not conducive to business expansion. The more resident named pipes there are, the higher the resource utilization rate. When the resident named pipes are turned on on the server and the client, they are always in the open state and resources cannot be released.
[0066] Based on this, the present application embodiment provides a communication method between processes, see Figure 2 As shown, Figure 2 A schematic flow chart of an inter-process communication method provided in an embodiment of the present invention, the method is executed by a server, and the method steps include:
[0067] Step 210: Receive at least one communication interface request sent by the client through the pre-built primary named pipe.
[0068] Specifically, a main named pipe is first pre-built between the server and the client, the client sends an IPC interface request through the main named pipe, and the server receives the IPC interface request through the main named pipe.
[0069] In an optional example, such as a file download task, the server receives the file download task request from the client through the main named pipe. The download task request may include one or more.
[0070] Step 220: Generate a first temporary pipe name corresponding to the first communication interface request.
[0071] Specifically, the first communication interface request is any one of the at least one communication interface request. The server receives the interface request sent by the client, and generates a corresponding number of first temporary pipe names according to the number of the interface requests.
[0072] In an optional example, if the server receives one IPC interface request from the client, a first temporary pipe name Temporary Pipe 1 is generated. If there are three IPC interface requests, three temporary pipe names may be generated: Temporary Pipe 1, Temporary Pipe 2, and Temporary Pipe 3.
[0073] Step 230, all temporary pipe names are sent to the client through the main named pipe, so that the client can create a temporary pipe according to each temporary pipe name.
[0074] Specifically, all temporary pipe names are sent to the client through the main named pipe. After receiving the temporary pipe name, the client creates each temporary pipe according to the temporary pipe name.
[0075] In an optional example, for example, the temporary pipe names generated by the server are temporary pipe 1, temporary pipe 2, and temporary pipe 3, then all temporary pipe names are sent to the client through the main named pipe. After the client receives the temporary pipe names, it generates temporary pipe 1, temporary pipe 2, and temporary pipe 3 according to the temporary pipe names.
[0076] Step 240: Acquire first service processing data corresponding to the first communication interface request according to the first communication interface request.
[0077] Specifically, the server performs corresponding service processing according to the received first communication interface request and obtains service processing data.
[0078] In an optional example, for example, the communication interface request is: enumerate the local hardware information, then the server obtains the local hardware enumeration information according to the request, generates local hardware information enumeration data, that is, business processing data, or other Hypertext Transfer Protocol (HTTP) requests, etc., performs corresponding business processing according to the request information, and generates business data.
[0079] Step 250: Send the first service processing data to the client through the temporary pipe corresponding to the first temporary pipe name.
[0080] Specifically, the temporary pipe corresponding to the first business processing data is the first temporary pipe, and the business processing data and the temporary pipe have a one-to-one correspondence. After the server generates the first business processing data, it sends the first business processing data to the client through the first temporary pipe.
[0081] In this way, a temporary pipe name is generated according to the number of interface requests through the main named pipe and the temporary pipe name is sent to the client through the main named pipe, so that the client can create a corresponding temporary pipe according to the temporary pipe name and create it only when a request occurs, thereby avoiding communication blocking problems, reducing resource occupation, and improving resource utilization.
[0082] To make the program more convenient, you can choose to automatically generate unique temporary pipe names.
[0083] Optionally, generating a first temporary pipe name corresponding to the first communication interface request specifically includes:
[0084] A first temporary pipe name corresponding to the first communication interface request is generated using a globally unique identifier algorithm.
[0085] Specifically, a globally unique identifier (GUID) generated by a globally unique identifier algorithm may be used as the temporary pipe name to ensure that the temporary pipe name is not repeated and is not limited to the number of interface requests.
[0086] In this way, a temporary pipe name is generated using a globally unique identifier algorithm, which can avoid unnecessary system problems caused by duplicate pipe names.
[0087] After the business data is transmitted, the temporary pipeline can be closed to release the resources occupied by the temporary pipeline and improve resource utilization.
[0088] Optionally, after sending the first service processing data to the client through the first temporary pipe corresponding to the first temporary pipe name, the method further includes:
[0089] An instruction to close the temporary pipe corresponding to the first temporary pipe name is sent to the client.
[0090] Specifically, after the first business processing data, that is, any business processing data, is sent to the client through the corresponding temporary pipe, an instruction to close the temporary pipe can also be sent immediately. Because the client reads messages sequentially, after the client reads the business data, the temporary pipe can be immediately closed according to the instruction to close the temporary pipe.
[0091] In an optional example, after the server sends the corresponding business processing data through temporary pipe 1, it immediately sends an instruction to close temporary pipe 1. After the client reads the instruction, it can close temporary pipe 1 according to the instruction and release the resources occupied by temporary pipe 1.
[0092] In this way, after the temporary pipe has transmitted the business data, an instruction to close the temporary pipe is sent to the client, so that the client can close the temporary pipe according to the instruction, and the resources occupied by the temporary pipe can be released after the business data transmission is completed, thereby further improving resource utilization.
[0093] Optionally, before receiving at least one communication interface request sent by the client through the pre-built main named pipe, the method further includes:
[0094] Create a primary named pipe based on the preset primary pipe name.
[0095] Specifically, the server can agree on a main pipe name with the client. When the server starts, it creates a main named pipe according to the main pipe name. The client can connect to the main named pipe according to the main pipe name and send a communication interface request through the main named pipe.
[0096] In this way, a main named pipe is created according to the main pipe name pre-agreed by the server and the client, which is beneficial for the server and the client to connect to the main named pipe according to the main pipe name.
[0097] The above is the inter-process communication method performed by the server provided by the present invention. The present invention also provides an inter-process communication method performed by the client to complete the interaction with the server, specifically including the following steps: Figure 3 The method steps shown:
[0098] Step 310: Send at least one communication interface request to the server through the pre-built primary named pipe.
[0099] Specifically, the client connects to the pre-built main named pipe through the main named pipe agreed with the server, and sends a communication interface request to the client through the main named pipe. The number of requests can be one or more.
[0100] In an optional example, for example, the client sends a request to download multiple files, or a request to enumerate local hardware device information, etc. to the server.
[0101] Step 320: Receive a temporary pipe name corresponding to each communication interface request in at least one communication interface request sent by the server.
[0102] Specifically, after receiving the communication interface request, the server generates a temporary pipe name corresponding to the number of communication interface requests, and sends it to the client through the main named pipe. The client receives each temporary pipe name generated by the server through the main named pipe.
[0103] Step 330: Create a corresponding first temporary pipeline according to the first temporary pipeline name.
[0104] Specifically, the first temporary pipe name is a temporary pipe name corresponding to the first communication interface request, and the first communication interface request is any communication interface request of at least one communication interface request.
[0105] There is a one-to-one mapping relationship between the temporary pipe name and the communication interface request. After receiving the temporary pipe name, the client creates a temporary pipe corresponding to the temporary pipe name. Therefore, there is also a one-to-one mapping relationship between the temporary pipe and the communication interface request.
[0106] In an optional example, for example, the first communication interface request is to download file A, and the temporary pipe name corresponding to the first communication interface request generated by the server is temporary pipe A. When the client receives the temporary pipe name: temporary pipe A, it creates a temporary pipe named temporary pipe A, and temporary pipe A is used to transmit the information requested by the first communication interface.
[0107] Step 340: Receive the first business processing data returned by the server through the first temporary channel.
[0108] Specifically, the first business processing data is business processing data corresponding to the first communication interface request. After the server generates the business processing data according to the first communication interface request, it transmits the business processing data to the client through a temporary channel corresponding to the first communication interface request. The client receives the business processing data and performs subsequent processing or display.
[0109] In an optional example, for example, the first communication interface request is to download file A, and the corresponding temporary pipe is temporary pipe A, then the client receives the processing data file A of the request to download file A through temporary pipe A.
[0110] In this way, a communication interface request is sent through the main named pipe, and a temporary pipe is created according to the received temporary pipe name. The temporary pipe is created only when a request occurs, which avoids communication blocking problems, reduces resource usage, and improves resource utilization.
[0111] Optionally, after receiving the first business processing data returned by the server through the first temporary channel, the method further includes:
[0112] receiving, through the first temporary pipe, an instruction sent by the server to close the first temporary pipe;
[0113] Close the first temporary pipeline according to the instruction.
[0114] Specifically, after receiving the business processing data sent by the server through the first temporary pipe, the client also receives an instruction to close the first temporary pipe through the first temporary pipe, and closes the first temporary pipe according to the closing instruction.
[0115] In an optional example, for example, if the business data of downloading file A has been received, an instruction to close temporary pipe A is received through temporary pipe A, and temporary pipe A is closed.
[0116] In this way, after the business processing data transmission is completed, the temporary pipeline is closed according to the close command, which can release the resources occupied by the temporary pipeline and further improve resource utilization.
[0117] In order to make the method of the present invention more clear, the present invention also provides another interactive flow diagram of the inter-process communication method, as shown in FIG. Figure 4 Show:
[0118] The server creates a main named pipe according to the agreed main pipe name, and the client connects to the main named pipe through the main pipe name. The client sends at least one communication interface request to the server through the main named pipe: interface request 1 to interface request N. The server reads all communication interface requests, generates a number of temporary pipe names corresponding to the communication interface requests: temporary pipe 1 to temporary pipe N, and sends all temporary pipe names to the client through the main named pipe. The client reads the temporary pipe name and creates corresponding temporary pipes according to the temporary pipe name: temporary pipe 1 to temporary pipe N. The server connects to each temporary pipe and sends the processed business data: business data 1 to business data N to the client through the corresponding temporary pipe, and sends an instruction to close the temporary pipe after sending the business processing data. The client receives the corresponding business processing data through each temporary pipe, processes or displays the data, and then closes the corresponding temporary pipe according to the closing instruction.
[0119] The above is an embodiment of the inter-process communication method provided by the present application. The following is an introduction to other embodiments of the process communication provided by the present application. Please refer to the following for details.
[0120] Figure 5 An inter-process communication device provided in an embodiment of the present invention includes:
[0121] The receiving module 501 is used to receive at least one communication interface request sent by the client through a pre-built main named pipe;
[0122] A generating module 502, configured to generate a first temporary pipe name corresponding to a first communication interface request, wherein the first communication interface request is any one of the at least one communication interface request;
[0123] The sending module 503 is used to send all temporary pipe names to the client through the main named pipe, so that the client can create a temporary pipe according to each temporary pipe name;
[0124] The processing module 504 is used to obtain first service processing data corresponding to the first communication interface request according to the first communication interface request;
[0125] The sending module 503 is further configured to send the first service processing data to the client through a temporary pipe corresponding to the first temporary pipe name.
[0126] Optionally, the device comprises:
[0127] The generating module 502 is further configured to generate a first temporary pipe name corresponding to the first communication interface request by adopting a globally unique identifier algorithm.
[0128] Optionally, the device comprises:
[0129] The sending module 503 is further configured to send an instruction to the client to close the temporary pipe corresponding to the first temporary pipe name.
[0130] Optionally, the device further includes: a creation module 505;
[0131] The creation module 505 is used to create a main named pipe according to a preset main pipe name.
[0132] The functions performed by each component in the inter-process communication device provided by the embodiment of the present invention are as described above. Figure 2 A detailed description has been given in the illustrated embodiment, so it will not be repeated here.
[0133] An inter-process communication device provided by an embodiment of the present invention receives at least one communication interface request sent by a client through a pre-built main named pipe; generates a first temporary pipe name corresponding to the first communication interface request, wherein the first communication interface request is any communication interface request in at least one communication interface request; sends all temporary pipe names to the client through the main named pipe, so that the client creates temporary pipes according to each temporary pipe name; obtains first business processing data corresponding to the first communication interface request according to the first communication interface request; and sends the first business processing data to the client through the temporary pipe corresponding to the first temporary pipe name. In this way, a temporary pipe name is generated according to the number of interface requests through the main named pipe and the temporary pipe name is sent to the client through the main named pipe, so that the client creates a corresponding temporary pipe according to the temporary pipe name, and the creation is performed only when a request occurs, which avoids the problem of communication blocking, reduces resource occupation, improves resource utilization, and improves communication efficiency.
[0134] Figure 6 An inter-process communication device provided in an embodiment of the present invention includes:
[0135] The sending module 601 is used to send at least one communication interface request to the server through a pre-built main named pipe;
[0136] The receiving module 602 is used to receive a temporary pipe name corresponding to each communication interface request in at least one communication interface request sent by the server;
[0137] A creation module 603 is used to create a corresponding first temporary pipe according to a first temporary pipe name, wherein the first temporary pipe name is a temporary pipe name corresponding to a first communication interface request, and the first communication interface request is any communication interface request of at least one communication interface request;
[0138] The receiving module 602 is further configured to receive first business processing data returned by the server through the first temporary channel, wherein the first business processing data is business processing data corresponding to the first communication interface request.
[0139] Optionally, the device includes: a closing module 604;
[0140] The receiving module 602 is further configured to receive, through the first temporary pipe, an instruction sent by the server to close the first temporary pipe;
[0141] The closing module 604 is used to close the first temporary pipeline according to the instruction.
[0142] The functions performed by each component in the inter-process communication device provided by the embodiment of the present invention are as described above. Figure 3 A detailed description has been given in the illustrated embodiment, so it will not be repeated here.
[0143] An inter-process communication device provided by an embodiment of the present invention sends at least one communication interface request to a server through a pre-constructed main named pipe; receives a temporary pipe name corresponding to each communication interface request in the at least one communication interface request sent by the server; creates a corresponding first temporary pipe according to the first temporary pipe name, wherein the first temporary pipe name is a temporary pipe name corresponding to the first communication interface request, and the first communication interface request is any communication interface request in the at least one communication interface request; receives the first business processing data returned by the server through the first temporary pipe, wherein the first business processing data is the business processing data corresponding to the first communication interface request. In this way, a communication interface request is sent through the main named pipe, and a temporary pipe is created according to the received temporary pipe name, and the creation is performed only when a request occurs, which avoids the problem of communication blocking, reduces resource occupation, improves resource utilization, and improves communication efficiency.
[0144] like Figure 7As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0145] Memory 113, used for storing computer programs;
[0146] In one embodiment of the present application, when the electronic device includes a server, the processor 111 is configured to execute the following steps: Figure 2 The method steps shown are as follows:
[0147] receiving at least one communication interface request sent by a client through a pre-built main named pipe;
[0148] Generate a first temporary pipe name corresponding to a first communication interface request, wherein the first communication interface request is any one of the at least one communication interface request;
[0149] Send all temporary pipe names to the client through the main named pipe, so that the client can create temporary pipes according to each temporary pipe name;
[0150] Acquire first service processing data corresponding to the first communication interface request according to the first communication interface request;
[0151] The first business processing data is sent to the client through a temporary pipe corresponding to the first temporary pipe name.
[0152] Optionally, generating a first temporary pipe name corresponding to the first communication interface request specifically includes:
[0153] A first temporary pipe name corresponding to the first communication interface request is generated using a globally unique identifier algorithm.
[0154] Optionally, after sending the first service processing data to the client through the first temporary pipe corresponding to the first temporary pipe name, the method further includes:
[0155] An instruction to close the temporary pipe corresponding to the first temporary pipe name is sent to the client.
[0156] Optionally, before receiving at least one communication interface request sent by the client through the pre-built main named pipe, the method further includes:
[0157] Create a primary named pipe based on the preset primary pipe name.
[0158] In another embodiment of the present application, when the electronic device includes a client, the processor 111 is configured to execute the following steps: Figure 3The method steps shown are as follows:
[0159] Send at least one communication interface request to the server through a pre-built primary named pipe;
[0160] receiving a temporary pipe name corresponding to each of the at least one communication interface request sent by the server;
[0161] Creating a corresponding first temporary pipe according to the first temporary pipe name, wherein the first temporary pipe name is a temporary pipe name corresponding to the first communication interface request, and the first communication interface request is any communication interface request of the at least one communication interface request;
[0162] The first business processing data returned by the server is received through the first temporary pipeline, wherein the first business processing data is business processing data corresponding to the first communication interface request.
[0163] Optionally, after receiving the first business processing data returned by the server through the first temporary channel, the method further includes:
[0164] receiving, through the first temporary pipe, an instruction sent by the server to close the first temporary pipe;
[0165] Close the first temporary pipeline according to the instruction.
[0166] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figure 2 The steps of the inter-process communication method provided by any one of the method embodiments shown in the figure, or, implementing the method as follows Figure 3 The steps of any inter-process communication method shown.
[0167] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0168] The above is only a specific embodiment of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but should conform to the widest scope consistent with the principles and novel features applied herein.
Claims
1. A method for communication between processes, characterized in that: The method is executed by the server, and includes: receiving at least one communication interface request sent by a client through a pre-built main named pipe; Generate a first temporary pipe name corresponding to a first communication interface request, wherein the first communication interface request is any one of the at least one communication interface request; Sending all temporary pipe names to the client through the main named pipe, so that the client creates a temporary pipe according to each temporary pipe name; Acquire first service processing data corresponding to the first communication interface request according to the first communication interface request; The first business processing data is sent to the client through a temporary pipe corresponding to the first temporary pipe name; the business processing data and the temporary pipe have a one-to-one correspondence.
2. The method according to claim 1, characterized in that The generating of a first temporary pipe name corresponding to the first communication interface request specifically includes: A first temporary pipe name corresponding to the first communication interface request is generated using a globally unique identifier algorithm.
3. The method according to claim 1 or 2, characterized in that: After sending the first service processing data to the client through the first temporary pipe corresponding to the first temporary pipe name, the method further includes: An instruction to close the temporary pipe corresponding to the first temporary pipe name is sent to the client.
4. The method according to claim 1 or 2, characterized in that: Before receiving at least one communication interface request sent by the client through the pre-built main named pipe, the method further includes: Create a primary named pipe based on the preset primary pipe name.
5. A method for communication between processes, characterized in that: The method is executed by a client, and includes: Send at least one communication interface request to the server through a pre-built primary named pipe; Receiving a temporary pipe name corresponding to each of the at least one communication interface request sent by the server; Creating a corresponding first temporary pipe according to a first temporary pipe name, wherein the first temporary pipe name is a temporary pipe name corresponding to a first communication interface request, and the first communication interface request is any one of at least one communication interface request; The first business processing data returned by the server is received through the first temporary pipe, wherein the first business processing data is business processing data corresponding to the first communication interface request; and the business processing data and the temporary pipe have a one-to-one correspondence.
6. The method according to claim 5, characterized in that After receiving the first business processing data returned by the server through the first temporary channel, the method further includes: receiving, through the first temporary pipe, an instruction sent by the server to close the first temporary pipe; The first temporary pipe is closed according to the instruction.
7. An inter-process communication device, characterized in that: The device comprises: A receiving module, used for receiving at least one communication interface request sent by a client through a pre-built main named pipe; A generating module, configured to generate a first temporary pipe name corresponding to a first communication interface request, wherein the first communication interface request is any one of the at least one communication interface request; A sending module, used for sending all temporary pipe names to the client through the main named pipe, so that the client can create a temporary pipe according to each temporary pipe name; A processing module, configured to obtain first service processing data corresponding to the first communication interface request according to the first communication interface request; The sending module is further used to send the first business processing data to the client through a temporary pipe corresponding to the first temporary pipe name; the business processing data and the temporary pipe have a one-to-one correspondence.
8. An inter-process communication device, characterized in that: The device comprises: A sending module, used for sending at least one communication interface request to the server through a pre-built main named pipe; A receiving module, used for receiving a temporary pipe name corresponding to each of the at least one communication interface request sent by the server; a creation module, configured to create a corresponding first temporary pipe according to a first temporary pipe name, wherein the first temporary pipe name is a temporary pipe name corresponding to a first communication interface request, and the first communication interface request is any one of at least one communication interface request; The receiving module is further used to receive the first business processing data returned by the server through the first temporary pipeline, wherein the first business processing data is the business processing data corresponding to the first communication interface request; the business processing data and the temporary pipeline have a one-to-one correspondence.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the steps of the inter-process communication method described in any one of claims 1-4 when executing the program stored in the memory; or, implement the steps of the inter-process communication method described in any one of claims 5-6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the inter-process communication method described in any one of claims 1 to 4 are implemented; or, the steps of the inter-process communication method described in any one of claims 5 to 6 are implemented.
Citation Information
Patent Citations
Request message processing and transmitting method and device
CN105553977A
Duplex communication method based on FIFO (first in first out) named pipes and related equipment
CN108833578A