CN114416383A - A kind of multi-process communication method and device - Google Patents
A kind of multi-process communication method and device Download PDFInfo
- Publication number
- CN114416383A CN114416383A CN202111498701.9A CN202111498701A CN114416383A CN 114416383 A CN114416383 A CN 114416383A CN 202111498701 A CN202111498701 A CN 202111498701A CN 114416383 A CN114416383 A CN 114416383A
- Authority
- CN
- China
- Prior art keywords
- application
- data
- port
- communication
- application process
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 379
- 238000004891 communication Methods 0.000 title claims abstract description 108
- 230000008569 process Effects 0.000 claims abstract description 279
- 238000012546 transfer Methods 0.000 claims abstract description 71
- 230000001360 synchronised effect Effects 0.000 claims abstract description 14
- 238000004590 computer program Methods 0.000 claims description 15
- 238000012545 processing Methods 0.000 claims description 15
- 230000004044 response Effects 0.000 claims description 14
- 238000012544 monitoring process Methods 0.000 abstract description 16
- 238000010586 diagram Methods 0.000 description 10
- 230000007246 mechanism Effects 0.000 description 3
- 239000008186 active pharmaceutical agent Substances 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000006855 networking Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/52—Program synchronisation; Mutual exclusion, e.g. by means of semaphores
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer And Data Communications (AREA)
Abstract
Description
技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种多进程通信方法及装置。The present invention relates to the field of computer technology, and in particular, to a multi-process communication method and device.
背景技术Background technique
进程是指在系统中正在运行的一个应用程序,每个进程之间是独立的,每个进程均运行在其专用且受保护的内存空间内,比如同时打开QQ、微信,系统就会分别启动2个进程。进程间通信就是在不同进程之间传播或交换信息。对于iOS端的跨进程通信,进程的用户空间是互相独立的,一般而言是不能互相访问的。A process refers to an application running in the system. Each process is independent, and each process runs in its dedicated and protected memory space. For example, if QQ and WeChat are opened at the same time, the system will start separately. 2 processes. Interprocess communication is the dissemination or exchange of information between different processes. For cross-process communication on the iOS side, the user spaces of the processes are independent of each other and generally cannot access each other.
发明内容SUMMARY OF THE INVENTION
针对现有技术中的问题,本发明实施例提供一种多进程通信方法、设备、介质和产品。主要处理在零信任IOS场景下,NetworkExtension插件所在的进程(即中转进程)和主APP所在的进程(应用进程)之间的全双工通信问题。可以实现IOS端多进程协作场景下的数据同步方法,可实现一对一、一对多、多对多等各个进程的两两互相通信,提升跨进程通信的稳定性、实时性、高效性。本发明可在例如身份鉴别,访问控制,跨进程通信,数据同步等场景下应用。In view of the problems in the prior art, the embodiments of the present invention provide a multi-process communication method, device, medium and product. It mainly deals with the full-duplex communication between the process where the NetworkExtension plug-in is located (that is, the transfer process) and the process where the main APP is located (application process) in the zero-trust IOS scenario. It can realize the data synchronization method in the multi-process cooperation scenario on the IOS side, and can realize the mutual communication of each process such as one-to-one, one-to-many, many-to-many, etc., and improve the stability, real-time and efficiency of cross-process communication. The present invention can be applied in scenarios such as identity authentication, access control, cross-process communication, data synchronization and the like.
具体地,本发明实施例提供了以下技术方案:Specifically, the embodiments of the present invention provide the following technical solutions:
第一方面,本发明实施例提供了一种多进程通信方法,应用于IOS端的中转进程,包括:建立所述中转进程,并根据通信协议,建立对应所述中转进程的监听端口,所述监听端口用于与所述至少一个应用进程进行数据通信;通过所述监听端口,接收第一应用进程通过对应的第一应用端口发出的第一数据,根据所述第一数据进行业务操作。In a first aspect, an embodiment of the present invention provides a multi-process communication method, which is applied to a relay process on an IOS side, including: establishing the relay process, and establishing a listening port corresponding to the relay process according to a communication protocol, and the monitoring The port is used for data communication with the at least one application process; through the listening port, first data sent by the first application process through the corresponding first application port is received, and business operations are performed according to the first data.
进一步地,所述方法还包括:通过所述监听端口,将所述第一数据同步至第二应用进程,所述至少一个应用进程包括所述第二应用进程,所述第二应用进程通过对应的第二应用端口接收数据;和/或响应于所述中转进程更新数据,通过所述监听端口,将更新后的第二数据同步至所述第一应用进程,所述第一应用进程通过对应的第一应用端口接收数据;和/或响应于所述中转进程更新数据,通过所述监听端口,将更新后的第二数据同步至所述第二应用进程。Further, the method further includes: synchronizing the first data to a second application process through the listening port, the at least one application process includes the second application process, and the second application process through the corresponding and/or in response to the transfer process updating data, synchronize the updated second data to the first application process through the listening port, and the first application process passes the corresponding and/or synchronizing the updated second data to the second application process through the listening port in response to the data being updated by the relay process.
进一步地,所述建立所述中转进程,包括:安装NetworkExtension插件,通过启动所述插件建立所述中转进程。Further, the establishing the transfer process includes: installing a NetworkExtension plug-in, and establishing the transfer process by starting the plug-in.
进一步地,所述通信协议包括WebSocket协议。Further, the communication protocol includes the WebSocket protocol.
第二方面,本发明实施例还提供了一种多进程通信方法,应用于IOS端的应用进程,包括:根据通信协议,建立对应至少一个应用进程的至少一个应用端口,所述至少一个应用端口用于与中转进程进行数据通信;响应于至少一个应用进程中的第一应用进程更新数据,通过对应所述第一应用进程的第一应用端口,将更新后的第一数据同步至所述中转进程,所述中转进程通过对应的监听端口接收数据。In a second aspect, an embodiment of the present invention further provides a multi-process communication method, which is applied to an application process on an IOS side, including: establishing at least one application port corresponding to at least one application process according to a communication protocol, the at least one application port using performing data communication with the transfer process; in response to the first application process in at least one application process updating data, synchronizing the updated first data to the transfer process through the first application port corresponding to the first application process , the transfer process receives data through the corresponding listening port.
进一步地,所述至少一个应用进程包括第二应用进程,以及所述方法还包括:通过对应所述第二应用进程的第二应用端口,接收所述中转进程通过所述监听端口发出的第一数据;和/或所述第一应用进程通过所述第一应用端口接收所述中转进程通过所述监听端口发出的第二数据,根据所述第二数据进行业务操作;和/或所述第二应用进程通过所述第二应用端口接收所述中转进程通过所述监听端口发出的第二数据,根据所述第二数据进行业务操作。Further, the at least one application process includes a second application process, and the method further includes: receiving, through a second application port corresponding to the second application process, the first message sent by the relay process through the listening port. and/or the first application process receives second data sent by the relay process through the listening port through the first application port, and performs business operations according to the second data; and/or the first application process The second application process receives, through the second application port, the second data sent by the transit process through the listening port, and performs business operations according to the second data.
进一步地,所述通信协议包括WebSocket协议。Further, the communication protocol includes the WebSocket protocol.
第三方面,本发明实施例还提供了一种多进程通信装置,其特征在于,应用于IOS端的中转进程,包括:第一处理模块,用于建立所述中转进程,并根据通信协议,建立对应所述中转进程的监听端口,所述监听端口用于与所述至少一个应用进程进行数据通信;第二处理模块,用于通过所述监听端口,接收第一应用进程通过对应的第一应用端口发出的第一数据,根据所述第一数据进行业务操作In a third aspect, an embodiment of the present invention also provides a multi-process communication device, characterized in that the transfer process applied to the IOS side includes: a first processing module, configured to establish the transfer process, and according to the communication protocol, establish a listening port corresponding to the relay process, the listening port is used for data communication with the at least one application process; a second processing module is used to receive the first application process through the corresponding first application through the listening port The first data sent by the port, and the business operation is performed according to the first data
第四方面,本发明实施例还提供了一种多进程通信装置,其特征在于,应用于IOS端的应用进程,包括:第四处理模块,用于根据通信协议,建立对应至少一个应用进程的至少一个应用端口,所述至少一个应用端口用于与中转进程进行数据通信;第五处理模块,用于响应于至少一个应用进程中的第一应用进程更新数据,通过对应所述第一应用进程的第一应用端口,将更新后的第一数据同步至所述中转进程,所述中转进程通过对应的监听端口接收数据。In a fourth aspect, an embodiment of the present invention also provides a multi-process communication device, wherein the application process applied to the IOS side includes: a fourth processing module, configured to establish at least one corresponding to at least one application process according to a communication protocol. An application port, the at least one application port is used for data communication with the transfer process; the fifth processing module is used for updating data in response to the first application process in the at least one application process, The first application port synchronizes the updated first data to the transfer process, and the transfer process receives data through the corresponding listening port.
第五方面,本发明实施例还提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现如第一方面所述多进程通信方法的步骤。In a fifth aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, the processor implements the first method when executing the program. The steps of the multi-process communication method described in the aspect.
第六方面,本发明实施例还提供了一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如第一方面所述多进程通信方法的步骤。In a sixth aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the steps of the multi-process communication method described in the first aspect .
第七方面,本发明实施例还提供了一种计算机程序产品,其上存储有可执行指令,该指令被处理器执行时使处理器实现第一方面所述多进程通信方法的步骤。In a seventh aspect, an embodiment of the present invention further provides a computer program product that stores executable instructions thereon, and when the instructions are executed by the processor, enables the processor to implement the steps of the multi-process communication method described in the first aspect.
本发明实施例提供的多进程通信方法,应用于IOS端的中转进程,建立对应所述中转进程的监听端口,并通过监听端口接收进程发出的数据,实现了iOS端对进程数据及时同步。The multi-process communication method provided by the embodiment of the present invention is applied to the relay process on the IOS side, establishes a monitoring port corresponding to the relay process, and receives data sent by the process through the monitoring port, so that the iOS terminal can synchronize the process data in time.
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description These are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained according to these drawings without creative efforts.
图1为本发明多进程通信方法实施例流程图;1 is a flowchart of an embodiment of a multi-process communication method according to the present invention;
图2为本发明多进程通信方法的另一些实施例流程图;FIG. 2 is a flow chart of other embodiments of the multi-process communication method of the present invention;
图3为在零信任场景中,本发明的整体结构与逻辑的一个应用场景的示意图;3 is a schematic diagram of an application scenario of the overall structure and logic of the present invention in a zero-trust scenario;
图4为在零信任场景中,中转进程将数据同步到其他进程的应用场景的示意图;FIG. 4 is a schematic diagram of an application scenario in which a transfer process synchronizes data to other processes in a zero-trust scenario;
图5为本发明多进程通信装置实施例结构示意图;FIG. 5 is a schematic structural diagram of an embodiment of a multi-process communication device according to the present invention;
图6为本发明多进程通信装置的另一些实施例结构示意图;FIG. 6 is a schematic structural diagram of another embodiment of the multi-process communication apparatus according to the present invention;
图7为本发明电子设备实体实施例结构示意图。FIG. 7 is a schematic structural diagram of a physical embodiment of an electronic device according to the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
图1为本发明多进程通信方法实施例流程图。如图1所示,本发明实施例的多进程通信方法,应用于IOS端的中转进程,包括:FIG. 1 is a flowchart of an embodiment of a multi-process communication method according to the present invention. As shown in FIG. 1 , the multi-process communication method according to the embodiment of the present invention is applied to the transfer process of the IOS side, including:
S101,建立中转进程,并根据通信协议,建立对应中转进程的监听端口,监听端口用于与至少一个应用进程进行数据通信。S101 , a transfer process is established, and according to a communication protocol, a listening port corresponding to the transfer process is established, and the listening port is used for data communication with at least one application process.
系统会为启动的软件分配一个进程,比如中转进程、应用进程。中转进程与至少一个应用进程进行数据通信,即跨进程通信,进程的用户空间是互相独立的,一般而言是不能互相访问的,进程间通信就是在不同进程之间传播或交换信息。由于IOS端的各个进程之间不能及时同步数据,因此,根据通信协议,建立对应中转进程的监听端口,通过监听端口与至少一个应用进程进行数据通信。各进程可以是对应同一个应用软件,也可以对应不同的应用软件。当某个进程发生数据更新时(或者完成某个任务时,使数据增加、删除或修改,或者查询数据),需要先将相关信息同步至中转进程,由中转进程的监听端口接收相关信息。The system will allocate a process for the started software, such as a transfer process and an application process. The transfer process communicates data with at least one application process, that is, cross-process communication. The user spaces of the processes are independent of each other and generally cannot access each other. Inter-process communication is to spread or exchange information between different processes. Since data cannot be synchronized between processes on the IOS side in time, a listening port corresponding to the transit process is established according to the communication protocol, and data communication is performed with at least one application process through the listening port. Each process may correspond to the same application software, or may correspond to different application software. When data is updated in a process (or when a certain task is completed, data is added, deleted, or modified, or data is queried), the relevant information needs to be synchronized to the transfer process first, and the listening port of the transfer process receives the relevant information.
S102,通过监听端口,接收第一应用进程通过对应的第一应用端口发出的第一数据,根据第一数据进行业务操作。S102: Receive first data sent by a first application process through a corresponding first application port through a listening port, and perform a service operation according to the first data.
作为示例,第一数据可以是需要更新的数据和指令,比如第一应用进程是关于注册用户账号的进程,当用户完成账号注册,第一应用进程需要将注册用户的用户名和密码通过第一应用端口同步到中转进程,中转进程的监听端口接收到用户名和密码后,将用户名和密码写入数据库。As an example, the first data may be data and instructions that need to be updated. For example, the first application process is a process of registering a user account. When the user completes account registration, the first application process needs to pass the user name and password of the registered user through the first application process. The port is synchronized to the transfer process. After the listening port of the transfer process receives the user name and password, the user name and password are written into the database.
本发明实施例提供的多进程通信方法,应用于IOS端的中转进程,建立对应中转进程的监听端口,并通过监听端口接收进程发出的数据,实现了iOS端对进程数据及时同步。The multi-process communication method provided by the embodiment of the present invention is applied to the relay process on the IOS side, establishes a monitoring port corresponding to the relay process, and receives data sent by the process through the monitoring port, so that the iOS terminal can synchronize the process data in time.
进一步地,在上述方法实施例的基础上,还可以包括:通过监听端口,将第一数据同步至第二应用进程,至少一个应用进程包括第二应用进程,第二应用进程通过对应的第二应用端口接收数据;和/或响应于中转进程更新数据,通过监听端口,将更新后的第二数据同步至第一应用进程,第一应用进程通过对应的第一应用端口接收数据;和/或响应于中转进程更新数据,通过监听端口,将更新后的第二数据同步至第二应用进程。Further, on the basis of the above method embodiments, it may also include: synchronizing the first data to the second application process through the listening port, at least one application process includes the second application process, and the second application process passes the corresponding second application process. The application port receives the data; and/or updates the data in response to the transfer process, synchronizes the updated second data to the first application process through the listening port, and the first application process receives the data through the corresponding first application port; and/or In response to the transfer process updating the data, the updated second data is synchronized to the second application process through the listening port.
第一/二应用进程是同一个IOS端的进程,当中转进程接收到第一应用进程的第一数据后,可以将第一数据同步至第二应用进程;同样的,当中转进程更新数据后,也可以将更新后的第二数据同步到其他进程中。The first/second application process is the same IOS-side process. After the intermediate process receives the first data of the first application process, it can synchronize the first data to the second application process; similarly, after the intermediate process updates the data, The updated second data may also be synchronized to other processes.
进一步地,在上述方法实施例的基础上,建立中转进程,包括:安装NetworkExtension插件,通过启动插件建立中转进程。Further, on the basis of the above method embodiments, establishing a transfer process includes: installing a NetworkExtension plug-in, and establishing a transfer process by starting the plug-in.
NetworkExtension插件,包含在iOS和macOS中用于自定义和拓展核心网络功能的API集合。它可给系统WiFi列表,列表里边的WiFi设置密码、标签(副标题)来直接点击连接。还可获取整个WiFi列表。通过NetworkExtension插件自定义和拓展核心网络功能的API集合,在iOS手机端实现轻量级的C-S架构模型,即通过中转进程,完成其他应用软件进程之间的通信。The NetworkExtension plugin contains a collection of APIs for customizing and extending core networking functionality in iOS and macOS. It can set the password and label (subtitle) for the WiFi list in the system to directly click to connect. Also get the entire WiFi list. Customize and expand the API set of core network functions through the NetworkExtension plug-in, and implement a lightweight C-S architecture model on the iOS mobile phone, that is, through the transfer process, to complete the communication between other application software processes.
进一步地,在上述方法实施例的基础上,通信协议可以包括WebSocket协议。Further, on the basis of the foregoing method embodiments, the communication protocol may include the WebSocket protocol.
WebSocket是一种在单个TCP连接上进行全双工通信的协议。传输控制协议/网际协议(Transmission Control Protocol/Internet Protocol,简称TCP/IP)。进程之间以一依据WebSocket协议通信。WebSocket is a protocol for full-duplex communication over a single TCP connection. Transmission Control Protocol/Internet Protocol (TCP/IP for short). Communication between processes is based on the WebSocket protocol.
如图3所示,为在零信任场景中,本发明的整体结构与逻辑的一个应用场景的示意图,零信任(Zero Trust,简称ZT)提供了一系列概念和思想,在假定网络环境已经被攻陷的前提下,当执行信息系统和服务中的每次访问请求时,降低其决策准确度的不确定性。零信任架构(ZTA)则是一种企业网络安全的规划,它基于零信任理念,围绕其组件关系、工作流规划与访问策略构建而成,在图3中,基于WebSocket协议,创建了中转进程Server进程,其记为S端,第一应用进程为Client1进程,其记为C1端,第二应用进程为Client2进程,其记为C2端。首先,通过NetworkExtension插件启动的WebSocket的Server服务,以及应用程序(Application,简称app)启动的WebSocket的C1端或C2端,当S端(主体)访问C端(客体)时,需要建立链接,发送数据,S端按数据信息操作流程。再比如,零信任中,进程MFA认证的场景(或其他多身份源场景,多因素认证场景)时,在C1端或C2端完成MFA之后,S端不知道,就需要给S端发送数据,让S端完成数据的刷新,同步数据。As shown in FIG. 3 , which is a schematic diagram of an application scenario of the overall structure and logic of the present invention in a zero trust scenario, Zero Trust (Zero Trust, ZT for short) provides a series of concepts and ideas, assuming that the network environment has been Under the premise of compromise, when each access request in information systems and services is executed, the uncertainty of its decision-making accuracy is reduced. Zero Trust Architecture (ZTA) is a plan for enterprise network security. It is based on the concept of zero trust and is built around its component relationships, workflow planning and access policies. In Figure 3, a transit process is created based on the WebSocket protocol. The server process is denoted as the S end, the first application process is the Client1 process, which is denoted as the C1 end, and the second application process is the Client2 process, which is denoted as the C2 end. First, the Server service of WebSocket started by the NetworkExtension plug-in, and the C1 or C2 side of WebSocket started by the application (Application, app for short), when the S side (subject) accesses the C side (object), it needs to establish a link, send Data, the S terminal operates the process according to the data information. For another example, in zero trust, in the process of MFA authentication (or other multi-identity source scenarios, multi-factor authentication scenarios), after completing MFA on the C1 or C2 end, the S end does not know, and needs to send data to the S end. Let the S side complete the data refresh and synchronize the data.
如图4所示,为在零信任场景中,中转进程将数据同步到其他进程的应用场景的示意图。在零信任中,S端会在收到Topic通知的时候有通知到C1端或C2端的强需求,因此,在这种场景下,会通过WebSocket通知到客户端(即C1端或C2端)。当有多个应用进程和中转进程链接的时,通过WebSocket就可以很方便的实现中转进程通知到所有应用进程的方式,极大的提高了跨进程通信的效率。As shown in FIG. 4 , it is a schematic diagram of an application scenario in which a transfer process synchronizes data to other processes in a zero-trust scenario. In zero trust, the S side will have a strong demand to notify the C1 side or the C2 side when it receives the Topic notification. Therefore, in this scenario, it will notify the client (ie, the C1 side or the C2 side) through WebSocket. When there are multiple application processes linked to the transfer process, the transfer process can be easily notified to all application processes through WebSocket, which greatly improves the efficiency of cross-process communication.
图2为本发明多进程通信方法的另一些实施例流程图。如图2所示,本发明实施例的多进程通信方法,应用于IOS端的应用进程,包括:FIG. 2 is a flow chart of other embodiments of the multi-process communication method of the present invention. As shown in FIG. 2 , the multi-process communication method according to the embodiment of the present invention, applied to the application process of the IOS side, includes:
S201,根据通信协议,建立对应至少一个应用进程的至少一个应用端口,至少一个应用端口用于与中转进程进行数据通信。S201 , according to the communication protocol, establish at least one application port corresponding to at least one application process, and the at least one application port is used for data communication with the transfer process.
在一些实施例中,中转进程和至少一个应用进程之间的通信协议可以是管道,其特点是半双工,即不能同时在两个方向上传输数据。有的系统可能支持全双工。只能在父子进程间。经典的形式就是管道由父进程创建,进程fork子进程之后,就可以在父子进程之间使用了。通信协议也可以是消息队列、信号量、共享内存、网络套接字等方式,可根据需要设定。In some embodiments, the communication protocol between the relay process and the at least one application process may be a pipe, which is characterized as half-duplex, ie, data cannot be transmitted in both directions at the same time. Some systems may support full duplex. Only between parent and child processes. The classic form is that the pipe is created by the parent process, and after the process forks the child process, it can be used between the parent and child processes. The communication protocol can also be a message queue, a semaphore, a shared memory, a network socket, etc., which can be set as needed.
S202,响应于至少一个应用进程中的第一应用进程更新数据,通过对应第一应用进程的第一应用端口,将更新后的第一数据同步至中转进程,中转进程通过对应的监听端口接收数据。S202, in response to the first application process in the at least one application process updating the data, synchronize the updated first data to the transfer process through the first application port corresponding to the first application process, and the transfer process receives the data through the corresponding listening port .
作为示例,第一数据可以包括需要更新的数据和指令,比如第一应用进程是关于注册用户账号的进程,当用户完成账号注册,第一应用进程需要将注册用户的用户名和密码通过第一应用端口同步到中转进程,中转进程的监听端口接收到用户名和密码后,将用户名和密码写入数据库。As an example, the first data may include data and instructions that need to be updated. For example, the first application process is a process for registering a user account. When the user completes account registration, the first application process needs to pass the user name and password of the registered user through the first application process. The port is synchronized to the transfer process. After the listening port of the transfer process receives the user name and password, the user name and password are written into the database.
本发明实施例提供的多进程通信方法,应用于IOS端的应用进程,至少一个应用进程通过至少一个应用端口与中转进程同步数据,进而实现至少一个应用进程之间的数据同步。The multi-process communication method provided by the embodiment of the present invention is applied to the application process of the IOS side, and at least one application process synchronizes data with the transfer process through at least one application port, thereby realizing data synchronization between at least one application process.
进一步地,在上述方法实施例的基础上,至少一个应用进程包括第二应用进程,以及方法还包括:通过对应第二应用进程的第二应用端口,接收中转进程通过监听端口发出的第一数据;和/或第一应用进程通过第一应用端口接收中转进程通过监听端口发出的第二数据,根据第二数据进行业务操作;和/或第二应用进程通过第二应用端口接收中转进程通过监听端口发出的第二数据,根据第二数据进行业务操作。Further, on the basis of the above method embodiments, at least one application process includes a second application process, and the method further includes: receiving, through a second application port corresponding to the second application process, the first data sent by the transit process through the listening port and/or the first application process receives the second data sent by the transfer process through the monitoring port through the first application port, and carries out business operations according to the second data; and/or the second application process receives the transfer process through the second application port by monitoring The second data sent by the port is used to perform service operations according to the second data.
IOS端的各个进程之间,可以通过中转进程完成数据同步,也可以执行中转进程发出的任务,执行业务操作,比如查询数据、验证等。Between the various processes on the IOS side, data synchronization can be completed through the transfer process, and tasks issued by the transfer process can also be executed to perform business operations, such as querying data and verifying.
进一步地,在上述方法实施例的基础上,通信协议包括WebSocket协议。Further, on the basis of the above method embodiments, the communication protocol includes the WebSocket protocol.
本发明可以在IOS手机端实现轻量级的C-S架构模型,以下简称,第一应用进程进程为C1进程、第二应用进程进程为C2进程,中转进程为S进程。The present invention can implement a lightweight C-S architecture model on the IOS mobile phone terminal, hereinafter referred to as the first application process process is the C1 process, the second application process process is the C2 process, and the transfer process is the S process.
在处理一对一的跨进程通信场景。通过Server进程启动一个WebSocket的S端(即服务端),在C1进程创建一个WebSocket的C1客户端,来链接Server进程的S端,实现C1-S高效的跨进程全双工通信机制;In dealing with one-to-one cross-process communication scenarios. Start a WebSocket S-side (ie server) through the Server process, and create a WebSocket C1 client in the C1 process to link the S-side of the Server process to realize the C1-S efficient cross-process full-duplex communication mechanism;
在处理一对多的跨进程通信场景。通过Server进程启动一个WebSocket的S端,在Client1进程创建一个WebSocket的C1客户端,来链接Server进程的S端,在Client2进程创建一个WebSocket的C2客户端,来链接Server进程的S端,实现C1-S/C2-S高效的跨进程全双工通信机制;In dealing with one-to-many cross-process communication scenarios. Start a WebSocket S-side through the Server process, create a WebSocket C1 client in the Client1 process to link the S-side of the Server process, and create a WebSocket C2 client in the Client2 process to link the S-side of the Server process to achieve C1 -S/C2-S efficient cross-process full-duplex communication mechanism;
在处理多对多的跨进程通信场景。通过Server进程启动一个WebSocket的S端,在Client1进程创建一个WebSocket的C1客户端,来链接Server进程的S端,在Client2进程创建一个WebSocket的C2客户端,来链接Server进程的S端,通过S端作为中转。实现多端互相通信的C1-S/C2-S/C1-S-C2高效的跨进程通信机制。In dealing with many-to-many cross-process communication scenarios. Start a WebSocket S-side through the Server process, create a WebSocket C1 client in the Client1 process to link the S-side of the Server process, and create a WebSocket C2 client in the Client2 process to link the S-side of the Server process. end as a relay. A C1-S/C2-S/C1-S-C2 efficient cross-process communication mechanism for multi-terminal communication.
在多进程数据同步的时候,可以通过C-S之间的WebSocket链接,将数据从C端发送到S端,在S端完成数据同步需要的操作。When multi-process data is synchronized, the data can be sent from the C side to the S side through the WebSocket link between the C and S, and the operations required for data synchronization are completed on the S side.
零信任中当C端登录完成之后,如果需要在S端完成登录情况的同步,一般会将登录过程中产生的Token传递至S端,在S端完成登录,通过WebSocket的方式,可以很轻易的实现登录状态的同步。In zero trust, after the C-side login is completed, if the synchronization of the login situation needs to be completed on the S-side, the Token generated during the login process is generally passed to the S-side, and the login is completed on the S-side. Through WebSocket, it can be easily Synchronize login status.
零信任中当C端登录状态或应用数据发生变化之后,可以通过C-S之间的WebSocket链接,将登陆数据同步到S端,S端可以根据数据变化的场景进行对应的业务操作,比如立刻从网关刷新数据。In Zero Trust, when the login status of the C-side or the application data changes, the login data can be synchronized to the S-side through the WebSocket link between the C-S and the S-side. The S-side can perform corresponding business operations according to the data change scenarios, such as immediately from the gateway. Refresh data.
图5为本发明多进程通信装置实施例结构示意图。如图5所示,该基于多进程通信装置应用于IOS端的中转进程,包括:FIG. 5 is a schematic structural diagram of an embodiment of a multi-process communication apparatus according to the present invention. As shown in Figure 5, the multi-process-based communication device is applied to the transfer process of the IOS side, including:
第一处理模块501,用于建立中转进程,并根据通信协议,建立对应中转进程的监听端口,监听端口用于与至少一个应用进程进行数据通信;The
第二处理模块502,用于通过监听端口,接收第一应用进程通过对应的第一应用端口发出的第一数据,根据第一数据进行业务操作。The
可选地,装置还包括:Optionally, the device further includes:
第三处理模块,用于通过监听端口,将第一数据同步至第二应用进程,至少一个应用进程包括第二应用进程,第二应用进程通对应的第二应用端口接收数据;和/或a third processing module, configured to synchronize the first data to the second application process through the listening port, at least one application process includes the second application process, and the second application process receives data through the corresponding second application port; and/or
响应于中转进程更新数据,通过监听端口,将更新后的第二数据同步至第一应用进程,第一应用进程通过对应的第一应用端口接收数据;和/或In response to the transfer process updating the data, the updated second data is synchronized to the first application process through the listening port, and the first application process receives the data through the corresponding first application port; and/or
响应于中转进程更新数据,通过监听端口,将更新后的第二数据同步至第二应用进程。In response to the transfer process updating the data, the updated second data is synchronized to the second application process through the listening port.
可选地,第一处理模块501,还用于:Optionally, the
安装NetworkExtension插件,通过启动插件建立中转进程。Install the NetworkExtension plug-in, and establish the transfer process by starting the plug-in.
可选地,通信协议包括WebSocket协议。Optionally, the communication protocol includes the WebSocket protocol.
图6为本发明多进程通信装置实施例结构示意图。如图6所示,该基于多进程通信装置应用于IOS端的应用进程,包括:FIG. 6 is a schematic structural diagram of an embodiment of a multi-process communication apparatus according to the present invention. As shown in Figure 6, the application process based on the multi-process communication device applied to the IOS side includes:
第四处理模块601,用于根据通信协议,建立对应至少一个应用进程的至少一个应用端口,至少一个应用端口用于与中转进程进行数据通信;The fourth processing module 601 is configured to establish at least one application port corresponding to at least one application process according to the communication protocol, and the at least one application port is used for data communication with the transfer process;
第五处理模块602,用于响应于至少一个应用进程中的第一应用进程更新数据,通过对应第一应用进程的第一应用端口,将更新后的第一数据同步至中转进程,中转进程通过对应的监听端口接收数据。The fifth processing module 602 is configured to update data in response to the first application process in the at least one application process, and synchronize the updated first data to the transfer process through the first application port corresponding to the first application process, and the transfer process passes The corresponding listening port receives data.
可选地,至少一个应用进程包括第二应用进程,装置还包括:Optionally, the at least one application process includes a second application process, and the apparatus further includes:
第六处理模块,用于通过对应第二应用进程的第二应用端口,接收中转进程通过监听端口发出的第一数据;和/或A sixth processing module, configured to receive, through the second application port corresponding to the second application process, the first data sent by the transfer process through the listening port; and/or
第一应用进程通过第一应用端口接收中转进程通过监听端口发出的第二数据,根据第二数据进行业务操作;和/或The first application process receives, through the first application port, the second data sent by the transit process through the listening port, and performs a business operation according to the second data; and/or
第二应用进程通过第二应用端口接收中转进程通过监听端口发出的第二数据,根据第二数据进行业务操作。The second application process receives, through the second application port, the second data sent by the transit process through the listening port, and performs business operations according to the second data.
可选地,通信协议包括WebSocket协议。Optionally, the communication protocol includes the WebSocket protocol.
举个例子如下:An example is as follows:
图7示例了一种电子设备的实体结构示意图,如图7示,该电子设备可以包括:处理器(processor)701、通信接口(Communications Interface)702、存储器(memory)703和通信总线704,其中,处理器701,通信接口702,存储器703通过通信总线704完成相互间的通信。处理器701可以调用存储器703中的逻辑指令,以执行如下方法:建立中转进程,并根据通信协议,建立对应中转进程的监听端口,监听端口用于与至少一个应用进程进行数据通信;通过监听端口,接收第一应用进程通过对应的第一应用端口发出的第一数据,根据第一数据进行业务操作。FIG. 7 illustrates a schematic diagram of the physical structure of an electronic device. As shown in FIG. 7 , the electronic device may include: a processor (processor) 701, a communication interface (Communications Interface) 702, a memory (memory) 703 and a communication bus 704, wherein , the processor 701 , the communication interface 702 , and the memory 703 communicate with each other through the communication bus 704 . The processor 701 can call the logic instruction in the memory 703 to perform the following method: establish a transfer process, and according to the communication protocol, establish a monitoring port corresponding to the transfer process, and the monitoring port is used for data communication with at least one application process; , receiving the first data sent by the first application process through the corresponding first application port, and performing service operations according to the first data.
此外,上述的存储器703中的逻辑指令可以通过软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。In addition, the above-mentioned logic instructions in the memory 703 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be embodied in the form of a software product in essence, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, Read-Only Memory (ROM, Read-Only Memory), Random Access Memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program codes .
另一方面,本发明实施例还提供一种计算机程序产品,计算机程序产品包括存储在非暂态计算机可读存储介质上的计算机程序,计算机程序包括程序指令,当程序指令被计算机执行时,计算机能够执行上述各实施例提供的多进程通信方法,例如包括:建立中转进程,并根据通信协议,建立对应中转进程的监听端口,监听端口用于与至少一个应用进程进行数据通信;通过监听端口,接收第一应用进程通过对应的第一应用端口发出的第一数据,根据第一数据进行业务操作。On the other hand, an embodiment of the present invention further provides a computer program product, the computer program product includes a computer program stored on a non-transitory computer-readable storage medium, the computer program includes program instructions, and when the program instructions are executed by a computer, the computer program The multi-process communication method provided by the above embodiments can be implemented, for example, including: establishing a relay process, and according to the communication protocol, establishing a monitoring port corresponding to the relay process, and the monitoring port is used for data communication with at least one application process; The first data sent by the first application process through the corresponding first application port is received, and the service operation is performed according to the first data.
又一方面,本发明还提供一种非暂态计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现以执行上述各实施例提供的多进程通信方法,例如包括:建立中转进程,并根据通信协议,建立对应中转进程的监听端口,监听端口用于与至少一个应用进程进行数据通信;通过监听端口,接收第一应用进程通过对应的第一应用端口发出的第一数据,根据第一数据进行业务操作。In another aspect, the present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored, and the computer program is implemented by a processor to execute the multi-process communication method provided by the above embodiments, for example, including : establish a transfer process, and according to the communication protocol, establish a listening port corresponding to the transfer process, and the listening port is used for data communication with at least one application process; through the listening port, receive the first application process sent by the first application process through the corresponding first application port. One data, and business operations are performed according to the first data.
以上所描述的装置实施例仅仅是示意性的,其中作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性的劳动的情况下,即可以理解并实施。The device embodiments described above are only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place , or distributed to multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分的方法。From the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and certainly can also be implemented by hardware. Based on this understanding, the above-mentioned technical solutions can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products can be stored in computer-readable storage media, such as ROM/RAM, magnetic Disks, optical discs, etc., include instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform the methods of various embodiments or portions of embodiments.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still be The technical solutions described in the foregoing embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims (12)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111498701.9A CN114416383A (en) | 2021-12-09 | 2021-12-09 | A kind of multi-process communication method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111498701.9A CN114416383A (en) | 2021-12-09 | 2021-12-09 | A kind of multi-process communication method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114416383A true CN114416383A (en) | 2022-04-29 |
Family
ID=81265303
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111498701.9A Pending CN114416383A (en) | 2021-12-09 | 2021-12-09 | A kind of multi-process communication method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114416383A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101087314A (en) * | 2007-05-15 | 2007-12-12 | 华为技术有限公司 | A system and method for application to use socket interface across processes |
CN102137123A (en) * | 2010-01-25 | 2011-07-27 | 腾讯科技(北京)有限公司 | Device and method for realizing process-to-process communication of different application programs on mobile terminal |
CN103209392A (en) * | 2012-01-16 | 2013-07-17 | 腾讯科技(深圳)有限公司 | Cross-process and multi-application massage pushing method and device |
US20160232045A1 (en) * | 2013-09-26 | 2016-08-11 | Continental Automotive Gmbh | User message queue method for inter-process communication |
-
2021
- 2021-12-09 CN CN202111498701.9A patent/CN114416383A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101087314A (en) * | 2007-05-15 | 2007-12-12 | 华为技术有限公司 | A system and method for application to use socket interface across processes |
CN102137123A (en) * | 2010-01-25 | 2011-07-27 | 腾讯科技(北京)有限公司 | Device and method for realizing process-to-process communication of different application programs on mobile terminal |
CN103209392A (en) * | 2012-01-16 | 2013-07-17 | 腾讯科技(深圳)有限公司 | Cross-process and multi-application massage pushing method and device |
US20160232045A1 (en) * | 2013-09-26 | 2016-08-11 | Continental Automotive Gmbh | User message queue method for inter-process communication |
Non-Patent Citations (2)
Title |
---|
WLAIZFF: "ios中Main App和Extensions之间的通信", 《CSDN》, 12 March 2016 (2016-03-12), pages 1 - 2 * |
李林静;叶冬芬;: "运用Winsock构建基于C/S模式的网络通信", 计算机工程与科学, no. 02, 15 February 2009 (2009-02-15) * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3726806B1 (en) | Method for remotely controlling vehicle on the basis of smart apparatus | |
JP6164747B2 (en) | Method for flow control in a collaborative environment and for reliable communication | |
US12160321B2 (en) | Multiplexing message distribution within group-based communication system | |
WO2017092347A1 (en) | Method, device and system for updating client configuration in memcached system | |
US20170163478A1 (en) | Method,electronic device and system for updating client configuration in key-value pair database | |
CN105531979B (en) | It is a kind of for exchanging the method and server of data between a client and a server | |
CN110808948B (en) | Remote procedure call method, device and system | |
CN106209966A (en) | Management and control end updates the method for equipment state, the treating method and apparatus of service end | |
CN102484655B (en) | Public robot management method and system in private networks | |
US20240231974A1 (en) | Method and system for inter-process communication | |
JP2024522611A (en) | Message Transfer Agent Architecture for Email Delivery Systems | |
CN102594886B (en) | Method and device for direct communication between browsers, and communication system | |
CN112181681A (en) | Remote calling method and device, computer equipment and storage medium | |
JP2018092565A (en) | Cloud relay device, cloud connection processing method, and program | |
CN116915827A (en) | Data transmission method, device, electronic equipment and media for Internet of Things edge gateway | |
CN115623057B (en) | RDMA-based connection establishment method, device, equipment and storage medium | |
CN110995829B (en) | Instance calling method and device and computer storage medium | |
CN104954321A (en) | Connection switching method, device and system | |
CN103024049B (en) | Realize the system that browser data is synchronous | |
CN105791361A (en) | Method, server, terminal and system for setting remote assistance | |
WO2021063399A1 (en) | Identity identifier authentication method for internet of things device, related apparatus, and system | |
CN110233791B (en) | Data deduplication method and device | |
WO2024222759A1 (en) | Association relationship establishment method and apparatus, device, storage medium, and program product | |
CN112202605A (en) | Service configuration method, device, equipment and storage medium | |
CN114416383A (en) | A kind of multi-process communication method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information | ||
CB02 | Change of applicant information |
Country or region after: China Address after: Room 332, 3 / F, Building 102, 28 xinjiekouwei street, Xicheng District, Beijing 100088 Applicant after: QAX Technology Group Inc. Applicant after: Qianxin Wangshen information technology (Beijing) Co.,Ltd. Address before: Room 332, 3 / F, Building 102, 28 xinjiekouwei street, Xicheng District, Beijing 100088 Applicant before: QAX Technology Group Inc. Country or region before: China Applicant before: LEGENDSEC INFORMATION TECHNOLOGY (BEIJING) Inc. |