A communication method, architecture, electronic device, and storage medium
By combining named pipes with target ports, centralized scheduling of multi-client communication is achieved, solving the problem of untimely inter-process communication in existing technologies and improving the stability and efficiency of communication.
Patent Information
- Application Number
- CN202610320173.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-16
- Publication Date
- 2026-07-31
AI Technical Summary
Existing inter-process communication methods suffer from untimely abnormal responses and limited application scenarios in complex scenarios, making it difficult to meet the needs for efficient and stable communication.
By creating a combination of named pipes and target ports, and using the target ports to uniformly manage the pipe events of named pipes, centralized scheduling of multi-client communication is achieved. Combined with event type identification and processing logic, communication stability and efficiency are improved.
It significantly improves the server's processing performance and resource utilization in high-concurrency communication scenarios, ensures the stability and efficiency of the communication link, and reduces resource consumption and unnecessary waiting.
Smart Images

Figure CN122489305A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of communication technology, and in particular to a communication method, architecture, electronic device, and storage medium. Background Technology
[0002] Inter-process communication (IPC) is the core mechanism for exchanging data and synchronizing operations between different processes. Common implementation methods include shared memory and message queues. However, these methods typically have limitations such as slow response to exceptions and restricted application scenarios, making it difficult to meet the needs of efficient and stable communication in complex scenarios. Summary of the Invention
[0003] In view of the above, this disclosure provides a communication method, architecture, electronic device, and storage medium.
[0004] According to a first aspect of this disclosure, a communication method is provided, the method comprising:
[0005] Create a named pipe for the client; The named pipe is associated with a target port, and the pipe event of the named pipe is obtained based on the target port; the pipe event is obtained based on the operation completion response obtained from the target port. Based on the event type corresponding to the pipeline event, execute the target action corresponding to the event type.
[0006] In one possible implementation, the method further includes: The pipeline event is parsed to obtain the status information corresponding to the pipeline event. The status information includes the event completion status, data transmission volume, and preset identification information. If the event completion status is successful and the data transmission volume is greater than zero, then the event type corresponding to the pipeline event is determined to be data transmission. If the event completion status is successful, the data transmission volume is zero, and the preset identification information is a preset exit identifier, then the event type corresponding to the pipeline event is determined to be normal exit. If the event completion status is failure or the preset identification information is a preset abnormal identification, then the event type corresponding to the pipeline event is determined to be abnormal exit.
[0007] In one possible implementation, the step of performing a target action corresponding to the event type based on the event type of the pipeline event includes: If the event type corresponding to the pipeline event is data transmission, then the business data transmitted by the named pipeline is processed to obtain the processing result; If the event type corresponding to the pipe event is normal exit, then release the system resources corresponding to the named pipe; If the event type corresponding to the pipeline event is abnormal exit, then cancel the suspended operation associated with the named pipeline and release the system resources corresponding to the named pipeline.
[0008] In one possible implementation, canceling the suspended operation associated with the named pipe and releasing the system resources corresponding to the named pipe includes: Based on the preset identification information, the abnormal exit type is determined, including pipeline disconnection and connection timeout; If the pipe is disconnected, cancel the suspension operation associated with the named pipe and release the system resources corresponding to the named pipe; If the connection times out, re-establish the connection between the named pipe and the client. If the connection fails, cancel the suspend operation associated with the named pipe and release the system resources corresponding to the named pipe.
[0009] In one possible implementation, creating the named pipe corresponding to the client includes: Receive connection requests sent by clients; Based on the connection request, obtain the digital signature of the client that initiated the connection request; Verify the digital signature; In response to the digital signature meeting preset conditions, a named pipe corresponding to the client is created.
[0010] In one possible implementation, processing the service data transmitted by the named pipe to obtain a processing result includes: The business data transmitted by the named pipe is stored in a preset message container; Based on preset reading rules, the target data to be interacted is determined from the business data stored in the preset message container; The target receiving end corresponding to the target data is determined, and the target data is sent to the target receiving end; the target receiving end is the client or the server. The target data is processed based on the target receiving end to obtain the processing result.
[0011] In one possible implementation, determining the target receiving end corresponding to the target data includes: The target data is parsed to determine the receiver identifier corresponding to the target data; Based on the receiver identifier, a matching target receiver is searched in the client container; wherein, the client container stores the identifiers of each client that has established a connection with the server and the corresponding named pipes.
[0012] According to a second aspect of this disclosure, a communication architecture is provided, the architecture including a server and at least one client; wherein the server is configured to: Create a named pipe for the client; The named pipe is associated with a target port, and the pipe event of the named pipe is obtained based on the target port; the pipe event is obtained based on the operation completion response obtained from the target port. Based on the event type corresponding to the pipeline event, execute the target action corresponding to the event type.
[0013] According to a third aspect of this disclosure, an electronic device is provided, comprising: At least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed, enables the at least one processor to perform the communication method described in the above embodiments.
[0014] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided that stores computer instructions for causing a computer acting as a server to execute the communication method described in the above embodiments.
[0015] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0016] The above and other objects, features, and advantages of this disclosure will become readily apparent from the following detailed description of exemplary embodiments, taken in conjunction with the accompanying drawings. Several embodiments of this disclosure are illustrated in the drawings by way of example and not limitation, in which: In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
[0017] Figure 1 A schematic diagram illustrating the implementation flow of the communication method according to an embodiment of this disclosure is shown; Figure 2 A schematic diagram of the communication architecture of an embodiment of this disclosure is shown. Figure 1 ; Figure 3 A schematic diagram of the communication architecture of an embodiment of this disclosure is shown. Figure 2 ; Figure 4 A schematic diagram of the composition structure of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation
[0018] To make the objectives, features, and advantages of this disclosure more apparent and understandable, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without creative effort are within the scope of protection of this disclosure.
[0019] This application provides a communication method, architecture, electronic device, and storage medium. The solution first creates a corresponding named pipe for each client, then associates the named pipe with a target port. It then obtains various operation completion responses from the named pipe through the target port, and extracts the corresponding pipe events. Finally, the server executes the target action corresponding to the event type based on the pipe event. This solution combines named pipes with target ports, allowing the target port to uniformly manage the named pipes for each client, converting various operations generated in the named pipes into standard pipe events, and achieving centralized scheduling of pipe events from multiple clients. Worker threads obtain notifications of completed operations through the target port; when there are no events, the threads are suspended, significantly reducing server resource consumption and unnecessary waiting, and significantly improving server processing performance and resource utilization in high-concurrency communication scenarios. Simultaneously, the server executes the corresponding target action based on the pipe event type, enabling rapid response to various client communication behaviors and ensuring the stability and efficiency of the communication link between the client and server.
[0020] The technical solution of this application will be described in detail below with reference to embodiments. A first aspect of this disclosure provides a communication method applied to a server. The server includes, but is not limited to, a server, computer equipment, or embedded processing device. Figure 1 As shown, the method includes the following steps: Step 101: Create the named pipe corresponding to the client.
[0021] A client is a terminal device, application instance, or process that establishes a communication connection with a server. When a client needs to interact with a server, it proactively initiates a connection request. Upon receiving the client's connection request, the server creates a corresponding named pipe for that client. This named pipe serves as a dedicated data transmission channel between the server and the corresponding client, enabling bidirectional data interaction between them.
[0022] Specifically, the server creates named pipes based on preset named pipe configuration rules, which include core parameters such as a unique pipe identifier, communication mode, and data transmission format. The unique pipe identifier is generated based on the client's identity information, ensuring a one-to-one correspondence between the named pipe and the client initiating the connection request. The communication mode defines the data interaction method of the pipe, and can use a message-based model to adapt to the high-efficiency transmission requirements of discrete business data. The data transmission format defines the encoding standards between the server and the client, ensuring consistency in data parsing between the two ends. After the server completes the creation of the named pipe, it binds the pipe to the client that initiated the request and marks it as the client's dedicated communication channel, allowing only the corresponding client to perform data sending and receiving operations through this channel.
[0023] Step 102: Associate the named pipe with the target port and obtain the pipe event of the named pipe based on the target port; the pipe event is obtained based on the operation completion response obtained from the target port.
[0024] This target port is a pre-configured event handling port on the server side used to monitor the communication status of the named pipes, such as an Input / Output Completion Port (IOCP), or other system ports that support asynchronous event monitoring. Its function is to act as an event relay hub between the named pipes and the server-side processing logic, capturing the completion status of various operations in the named pipes in real time and converting these operation results into pipe events that the server can recognize.
[0025] Specifically, the server first associates and binds the created client-specific named pipe with the target port, ensuring that all data transmissions, connection state changes, and other operations of the named pipe are uniformly collected and managed through the target port. When the client performs data write, read, or connection disconnection operations through the named pipe, the target port captures the completion status after the corresponding operation and generates a corresponding response signal. The server then further extracts the pipe events based on this response signal.
[0026] For example, after the client writes business data to the named pipe and completes the send operation, the target port captures the completion status of the data write operation and generates a response signal. The server extracts the corresponding pipe event based on this response signal, which is used to identify "the write operation has been completed".
[0027] Step 103: Based on the event type corresponding to the pipeline event, execute the target action corresponding to the event type.
[0028] The server creates corresponding worker threads based on the current system resource configuration and the preset thread creation strategy. These worker threads are not permanently bound to any client; they are only used to retrieve completed pipeline events from the target port and process them uniformly.
[0029] Specifically, the server selects an idle worker thread to acquire pipeline events. After acquiring the pipeline events, it parses and judges them based on preset event type identification rules to determine the specific event type corresponding to each event. These preset event type identification rules include the correspondence between the state information contained in the pipeline event and its corresponding event type. This event type is used to characterize the specific operational state generated by the named pipeline during communication, such as data reception events, data transmission events, normal exit events, or abnormal exit events.
[0030] After determining the specific event type of the pipeline event, the worker thread executes the target action corresponding to that event type. For example, if the event type is a data reception event, the worker thread reads the business data transmitted in the named pipeline, completes data parsing and subsequent business logic processing, generates the corresponding processing result, and sends it back to the client. After processing is complete, the worker thread returns to the thread pool.
[0031] This solution combines named pipes and target ports. The target port centrally manages all pipe events, requiring only a small number of worker threads to handle communication requests from multiple clients. This eliminates the need to allocate a dedicated thread for each client, significantly reducing the overhead of thread context switching and scheduling. Furthermore, the centralized and ordered processing of pipe events via the target port avoids lock contention overhead caused by multi-threaded competition. The server executes corresponding target actions based on the pipe event type, enabling rapid responses to various client communication behaviors and ensuring the stability and efficiency of the client-server communication link.
[0032] In another embodiment of this disclosure, the method further includes: parsing the pipeline event to obtain the status information corresponding to the pipeline event, the status information including time completion status, data transmission volume, and preset identification information; if the event completion status is successful and the data transmission volume is greater than zero, then the event type corresponding to the pipeline event is determined to be data transmission; if the time completion status is successful, the data transmission volume is zero, and the preset identification information is a preset exit identifier, then the event type corresponding to the pipeline event is determined to be normal exit; if the event completion status is failed or the preset identification information is a preset abnormal identifier, then the event type corresponding to the pipeline event is determined to be abnormal exit.
[0033] Pipe events include status information for various operations related to named pipes. The server parses the pipe events obtained from the target port and extracts the corresponding status information, mainly including event completion status, data transmission volume, and preset identification information.
[0034] The event completion status indicates whether the pipeline event's operation was successful. This can be represented by a Boolean value returned by a system function call or a system error code. For example, a Boolean value of "true / false" indicates whether the pipeline operation was successful or failed, such as the return value of the `GetQueuedCompletionStatus` function. The execution result can be further subdivided using system error codes, such as `ERROR_SEM_TIMEOUT` for connection timeout and `ERROR_BROKEN_PIPE` for abnormal pipeline interruption. Specific error codes are not limited. The data transmission volume indicates the number of bytes actually exchanged in the pipeline event, reflecting whether valid data was sent and received on the named pipe. A transmission volume of 0 indicates no valid data exchange. Predefined identifiers are dedicated identifiers predefined by the server to distinguish different communication scenarios. These can be fixed characters or specific values. For example, 00AA can be predefined as a normal exit identifier, 00BB as a normal data transmission identifier, and 00CC as an abnormal exit identifier.
[0035] After obtaining the event completion status, data transmission volume, and preset identifier information, the server determines the event type corresponding to the pipeline event based on the combination of these information. Specifically, if the event completion status is successful and the data transmission volume is greater than zero, it indicates that the pipeline operation was successfully executed and there was valid data transmission; in this case, the type of the pipeline event can be determined as data transmission. If the event completion status is successful, the data transmission volume is zero, and the preset identifier information matches the preset normal exit identifier, it indicates that there was no data interaction in this operation and the client actively disconnected the connection; the event type can be determined as normal exit. Normal exit means that the client disconnects from the named pipeline according to the standard procedure after completing business processing. If the event completion status is failed, or the preset identifier information matches the preset exception identifier, either condition indicates that an unexpected failure occurred in the pipeline operation; the event type can be determined as abnormal exit. Abnormal exit refers to scenarios where communication is interrupted due to unexpected reasons such as system errors, connection interruptions, or program exceptions.
[0036] The solution in this embodiment judges the pipeline event type by combining multi-dimensional information such as event completion status, data transmission volume, and preset identification information. This can more accurately distinguish between data transmission, normal exit, and abnormal exit scenarios, improve the accuracy and reliability of event type identification, help the server execute corresponding processing logic according to different event types, and enhance the stability of named pipe communication.
[0037] In another embodiment of this disclosure, based on the event type corresponding to the pipeline event, a target action corresponding to the event type is executed, including: if the event type corresponding to the pipeline event is data transmission, then the business data transmitted by the named pipeline is processed to obtain a processing result; if the event type corresponding to the pipeline event is normal exit, then the system resources corresponding to the named pipeline are released; if the event type corresponding to the pipeline event is abnormal exit, then the suspension operation associated with the named pipeline is canceled, and the system resources corresponding to the named pipeline are released.
[0038] Specifically, if the event type is a data reception event, it indicates that valid data has been written to the named pipe. At this point, the worker thread reads the transmitted business data from the corresponding named pipe based on the pipe handle and data length information carried in the pipe event, and parses and verifies the read business data according to a preset message format. The message format can use the Protobuf protocol, automatically generating serialization and deserialization logic through a predefined proto file to simplify the data parsing process; alternatively, a custom message format can be used, requiring custom-implemented serialization and deserialization functions to complete the data encoding and decoding. After completing data parsing and verification, the worker thread continues to execute subsequent business logic processing, ultimately generating the corresponding processing result.
[0039] If the event type is a normal exit event, it indicates that the client has completed all business interactions or has actively disconnected due to no further business needs, and the communication process has ended normally as expected. If the client has completed all business interactions and exited normally, the worker thread releases the system resources such as the pipe handle and data buffer occupied by the named pipe, marks the pipe as idle and reusable, and returns the current worker thread to the thread pool to continue processing other pipe events. If the client only temporarily pauses business and exits before completing all interactions, the worker thread only returns the corresponding business thread to the thread pool and does not release the system resources occupied by the named pipe temporarily, in order to avoid the need to repeatedly create the pipe and rebuild the connection when the client reconnects, thus reducing unnecessary system overhead.
[0040] If the event type is "Abnormal Exit Event," it indicates an unexpected failure during communication, such as abnormal connection interruption or client process crash, forcibly terminating the communication. In abnormal exit scenarios, named pipes typically have committed but incomplete input / output (IO) pending operations, such as suspended read, write, and listener operations. In this case, worker threads can call a thread cancellation function (such as `CancelIoEx`) to cancel all unfinished pending operations on the named pipe, terminating invalid asynchronous waits. Then, an exit notification is sent to the target port via event posting (such as calling the `PostQueuedCompletionStatus` function), informing the relevant worker threads to execute the exit logic. Finally, system resources such as the pipe handle, data buffer, and event listener resources are released to avoid resource leaks and invalid IO blocking.
[0041] The solution in this embodiment can execute targeted processing logic according to different event types. For normal exit events, it completes the orderly release of resources and pipeline reuse; for abnormal exit events, it first cancels suspended I / O operations and then releases resources. It can promptly process business data, complete resource reclamation or terminate invalid asynchronous operations, effectively avoid problems such as resource leakage, invalid I / O blocking, and thread contention, and significantly improve the stability, reliability and processing performance of server communication.
[0042] In another embodiment of this disclosure, canceling the suspended operation associated with the named pipe and releasing the system resources corresponding to the named pipe includes: determining the abnormal exit type based on preset identification information, the abnormal exit type including pipe disconnection and connection timeout; if the pipe is disconnected, canceling the suspended operation associated with the named pipe and releasing the system resources corresponding to the named pipe; if the connection times out, re-establishing the connection between the named pipe and the client; if the connection fails, canceling the suspended operation associated with the named pipe and releasing the system resources corresponding to the named pipe.
[0043] A pre-defined structure for identifying the causes of anomalies is established, which may include status codes, error types, or event flags. This allows the pre-defined identification information to intuitively reflect the triggering source of communication anomalies. Specifically, the status code is a pre-defined numerical code defined by the server to uniquely identify different anomaly scenarios; the error type is a semantic type description used to clarify the business meaning of the anomaly; and the event flag is a flag used to indicate whether an anomaly event has occurred. Based on the specific values of the above pre-defined identification information, the server can directly determine the specific type of abnormal exit. For example, a status code of 1001, an error type of DISCONNECT, and an event flag of 1 indicate an abnormal exit type of pipe disconnection; a status code of 1002, an error type of CONNECT_TIMEOUT, and an event flag of 2 indicate an abnormal exit type of connection timeout.
[0044] Among them, a pipe disconnection indicates a sudden interruption of the client connection, such as an abnormal crash of the client process or a forced disconnection of the communication link, which is an unrecoverable exception; a connection timeout indicates that the client has not performed data interaction or responded to the server's request within a preset time, such as network latency or temporary client lag, which is an exception that can be attempted to recover.
[0045] Therefore, if the current exception is detected as a pipe disconnection, the suspended operation associated with the named pipe is canceled directly, and the system resources corresponding to the named pipe are released; if the current exception is detected as a connection timeout, the reconnection logic is executed first to attempt to re-establish the communication connection between the server and the client; if the reconnection is successful, the normal communication process is restored; if the reconnection fails, the suspended operation associated with the named pipe is canceled again, and the system resources corresponding to the named pipe are released.
[0046] The solution in this embodiment improves communication recovery capability and resource utilization in abnormal scenarios while ensuring system stability by finely distinguishing abnormal exit types and adopting differentiated processing strategies for different abnormal types.
[0047] In another embodiment of this disclosure, the creation of a named channel corresponding to the client can be achieved through the following technical means: receiving a connection request sent by the client; obtaining the digital signature of the client that initiated the connection request based on the connection request; verifying the digital signature; and creating a named channel corresponding to the client in response to the digital signature meeting preset conditions.
[0048] When a client needs to establish a communication connection with a server, the client actively initiates a connection request to the server through its running process. After receiving the connection request from the client, the server does not directly create a dedicated named pipe for that client, but instead first triggers a process to verify the legitimacy of the client that initiated the connection request.
[0049] The specific legitimacy verification process is as follows: The server calls a standard interface provided by the operating system (such as GetNamedPipeClientProcessId) to obtain and determine the process identifier that initiated the connection request based on the current connection. Based on this process identifier, it calls a process information query interface to obtain the executable file path corresponding to the process. Based on this executable file path, it locates the executable file on the disk and calls the system signature verification interface to extract the digital signature from the executable file. This digital signature serves as an identity credential identifying the legitimacy of the client program, used to verify whether the program was published by a legitimate entity and has not been illegally tampered with.
[0050] The server verifies the extracted digital signature to determine if it meets preset conditions. Specifically, the server pre-configures the judgment rules that a legitimate digital signature must meet, and uses these as preset conditions. For example, preset conditions could be: the digital signature was issued by a certificate authority trusted by the server; the digital signature is within its validity period; and the issuer information of the digital signature matches the preset legitimate issuer information. The server then compares the obtained digital signature with the preset conditions.
[0051] If the digital signature meets the preset conditions, the client program is deemed legitimate, and the server creates a corresponding named pipe for the client to establish a dedicated communication channel. If the digital signature does not meet the preset conditions, the client program is deemed illegitimate, the server refuses to create a corresponding named pipe for the client, and disconnects the current connection request, thereby restricting access by unauthorized programs.
[0052] In another possible embodiment, the server can also obtain information such as process path, process owner identity, and process running parameters from the corresponding client process based on the process identifier, and combine this with the digital signature to perform multi-dimensional verification of the legitimacy of the client program, thereby further improving the accuracy of verification and system security.
[0053] The solution in this embodiment, by adding client legitimacy verification before creating named pipes, can effectively identify and intercept connection requests initiated by illegal processes, thereby improving the security and reliability of the communication system from the source of connection establishment and preventing unauthorized processes from accessing server resources.
[0054] In another embodiment of this disclosure, the business data transmitted via named pipe is processed to obtain a processing result, including: storing the business data transmitted via named pipe into a preset message container; determining the target data to be interacted with in the business data stored in the preset message container based on preset reading rules; determining the target receiving end corresponding to the target data and sending the target data to the target receiving end, wherein the target receiving end is a client or a server; and processing the target data based on the target receiving end to obtain a processing result.
[0055] The preset message container is a message cache area pre-configured by the server, such as a message queue, circular buffer, or message list. It is used for temporary storage, queuing, and scheduling of multiple business data messages received through the named pipe, preventing data loss or concurrent processing chaos. When the server receives business data from the client via the named pipe, or when the server needs to send business data to the client via the named pipe, the corresponding business data is first stored in the preset message container. Then, based on preset reading rules, one message is retrieved from the business data stored in the preset message container as the target data to be interacted with, i.e., the data that will soon enter the business processing flow. The preset reading rules can be set based on data processing strategies, such as First-In-First-Out (FIFO), priority scheduling, and filtering by message type.
[0056] The target receiver is then determined: if the target data is a command sent by the client that requires logical processing by the server, the target receiver is a worker thread within the server; if the target data is a message that the server needs to forward or reply to, the target receiver is the corresponding client. Once the target receiver is determined, the target data is sent to it, and the target receiver performs parsing, calculations, and responses on the target data, ultimately obtaining the corresponding processing result.
[0057] The solution in this embodiment introduces a message container to uniformly cache, queue, and schedule business data, and realizes orderly distribution and processing of data according to preset rules. This can effectively improve the stability of data transmission in high-concurrency scenarios, avoid data chaos and loss, and improve the server's processing efficiency and scheduling flexibility for business data.
[0058] In another embodiment of this disclosure, determining the target receiving end corresponding to the target data includes: parsing the target data to determine the identifier of the receiving end corresponding to the target data; and searching for a matching target receiving end in the client container based on the receiving end identifier; wherein the client container stores the identifiers of each client that has established a connection with the server and the corresponding named pipes.
[0059] The server pre-creates a client container to centrally manage information about all successfully established client connections. Client information includes a unique client identifier and the corresponding named pipe. After determining the target data to be exchanged, the server parses the target data, extracting a pre-agreed receiver identifier from the data header or message structure. This receiver identifier uniquely identifies the target recipient of the business data. Subsequently, based on this receiver identifier, the server iterates through the client container, searching for matching client information to locate the corresponding target receiver and its associated named pipe.
[0060] The number of target receivers can be one or more. When there is only one, it indicates that the current communication is point-to-point, that is, a one-to-one data interaction between the server and a single client, or the server forwards data to a specified single client. When there are multiple receivers, it indicates that the current communication is multicast or broadcast, that is, the server sends the same data to multiple clients simultaneously, and multiple receivers can receive and process the service data at the same time.
[0061] The solution in this embodiment manages online client information uniformly through a client container and achieves precise routing based on the receiver identifier. It can flexibly support various data interaction methods such as point-to-point communication, multicast communication, broadcast communication, and inter-client forwarding communication, ensuring that data can be accurately and efficiently sent to the target receiver.
[0062] A second aspect of this disclosure provides a communication architecture, such as... Figure 2 As shown, the architecture includes a server and at least one client; wherein, the server is used to: create a named pipe corresponding to the client; associate the named pipe with a target port, and obtain the pipe event of the named pipe based on the target port; obtain the operation completion response based on the pipe event obtained from the target port; and execute the target action corresponding to the event type based on the event type corresponding to the pipe event.
[0063] In another embodiment of this disclosure, the server is further configured to: parse the pipeline event and obtain the status information corresponding to the pipeline event, the status information including event completion status, data transmission volume, and preset identification information; if the event completion status is successful and the data transmission volume is greater than zero, then the event type corresponding to the pipeline event is determined to be data transmission; if the event completion status is successful, the data transmission volume is zero, and the preset identification information is a preset exit identifier, then the event type corresponding to the pipeline event is determined to be normal exit; if the event completion status is failed or the preset identification information is a preset abnormal identifier, then the event type corresponding to the pipeline event is determined to be abnormal exit.
[0064] In another embodiment of this disclosure, the server is further configured to: if the event type corresponding to the pipeline event is data transmission, process the business data transmitted by the named pipeline to obtain a processing result; if the event type corresponding to the pipeline event is normal exit, release the system resources corresponding to the named pipeline; if the event type corresponding to the pipeline event is abnormal exit, cancel the suspension operation associated with the named pipeline and release the system resources corresponding to the named pipeline.
[0065] In another embodiment of this disclosure, the server is further configured to: determine the abnormal exit type based on the preset identification information, wherein the abnormal exit type includes pipe disconnection and connection timeout; if it is pipe disconnection, cancel the suspension operation associated with the named pipe and release the system resources corresponding to the named pipe; if it is connection timeout, re-establish the connection between the named pipe and the client; if the connection fails, cancel the suspension operation associated with the named pipe and release the system resources corresponding to the named pipe.
[0066] In another embodiment of this disclosure, the server is further configured to: receive a connection request sent by a client; obtain a digital signature corresponding to the client that initiated the connection request based on the connection request; verify the digital signature; and create a named pipe corresponding to the client in response to the digital signature meeting a preset condition.
[0067] In another embodiment of this disclosure, the server is further configured to: store the business data transmitted by the named pipe into a preset message container; determine the target data to be interacted with in the business data stored in the preset message container based on preset reading rules; determine the target receiving end corresponding to the target data, and send the target data to the target receiving end; the target receiving end is the client or the server; process the target data based on the target receiving end to obtain the processing result.
[0068] In another embodiment of this disclosure, the server is further configured to: parse the target data to determine the receiver identifier corresponding to the target data; and search for a matching target receiver in the client container based on the receiver identifier; wherein the client container stores the identifiers of each client that has established a connection with the server and the corresponding named pipes.
[0069] This communication architecture and the above-mentioned communication method originate from the same technical concept. The specific implementation of the communication architecture can be found in the embodiments of the above-mentioned communication method, and will not be repeated here.
[0070] The following explanation uses a specific communication architecture as an example. Figure 3As shown, the architecture includes a server and three clients (Client 1, Client 2, and Client 3) that establish a connection with the server. The server has the following built-in functional units: an authentication unit to verify the identity and permissions of clients initiating connection requests, allowing them to establish a communication link with the server only if they meet preset legal access conditions; a client container to uniformly manage information about all successfully connected clients, including the client's unique identifier and the dedicated named pipe corresponding to that client; a communication interface definition to standardize the entire lifecycle operation interfaces of named pipes, such as creation, connection, reading, writing, and disconnection, unifying the communication behavior standard between the server and clients; and a message format definition to define the serialization and deserialization rules for business data, supporting standardized protocols such as Protobuf and also compatible with custom message formats, ensuring consistency in data parsing between the two ends.
[0071] In terms of specific processes, the server responds to connection requests from clients 1, 2, and 3 respectively. After completing the legality verification through the authentication unit, it creates a dedicated bidirectional named pipe 1, 2, and 3 for each client to establish a communication link. At the same time, it stores the unique identifier of each client and the corresponding named pipe information in the client container for unified management. When any client (such as client 1) sends business data to the server, the server receives the data through the corresponding dedicated named pipe and completes data parsing according to the message format definition. If the data needs to be forwarded to other clients (such as client 2), the server extracts the receiver identifier from the parsed data, searches for the matching target client and corresponding named pipe in the client container, and finally sends the data accurately to the target receiver, realizing point-to-point communication. In multicast or broadcast scenarios, multiple clients can be matched based on the receiver identifier to achieve multi-terminal data synchronization and interaction.
[0072] This example achieves secure, stable, and flexible communication between multiple clients by assigning a dedicated named pipe to each client and combining an authentication unit, client containers, and standardized communication and messaging rules. It also supports multiple data transmission modes such as point-to-point, multicast, and broadcast, effectively improving the reliability and scalability of the communication system.
[0073] According to embodiments of this disclosure, this disclosure also provides an electronic device and a readable storage medium.
[0074] Figure 4A schematic block diagram of an example electronic device that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0075] like Figure 4 As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.
[0076] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of monitors, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0077] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as communication methods. For example, in some embodiments, the communication method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the communication method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to perform the communication method by any other suitable means (e.g., by means of firmware).
[0078] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transferring data and instructions to the storage system, the at least one input device, and the at least one output device.
[0079] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0080] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0081] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0082] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0083] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0084] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this disclosure can be achieved, and this is not limited herein.
[0085] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this disclosure, "a plurality of" means two or more, unless otherwise explicitly specified.
[0086] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.
Claims
1. A communication method applied to a server, the method comprising: Create a named pipe for the client; The named pipe is associated with a target port, and the pipe event of the named pipe is obtained based on the target port; the pipe event is obtained based on the operation completion response obtained from the target port. Based on the event type corresponding to the pipeline event, execute the target action corresponding to the event type.
2. The method according to claim 1, further comprising: The pipeline event is parsed to obtain the status information corresponding to the pipeline event. The status information includes the event completion status, data transmission volume, and preset identification information. If the event completion status is successful and the data transmission volume is greater than zero, then the event type corresponding to the pipeline event is determined to be data transmission. If the event completion status is successful, the data transmission volume is zero, and the preset identification information is a preset exit identifier, then the event type corresponding to the pipeline event is determined to be normal exit. If the event completion status is failure or the preset identification information is a preset abnormal identification, then the event type corresponding to the pipeline event is determined to be abnormal exit.
3. The method according to claim 2, wherein performing a target action corresponding to the event type based on the event type corresponding to the pipeline event includes: If the event type corresponding to the pipeline event is the data transmission, then the business data transmitted by the named pipeline is processed to obtain the processing result; If the event type corresponding to the pipeline event is normal exit, then release the system resources corresponding to the named pipeline; If the event type corresponding to the pipeline event is abnormal exit, then cancel the suspension operation associated with the named pipeline and release the system resources corresponding to the named pipeline.
4. The method according to claim 3, wherein canceling the suspended operation associated with the named pipe and releasing the system resources corresponding to the named pipe includes: Based on the preset identification information, the abnormal exit type is determined, including pipeline disconnection and connection timeout; If the pipe is disconnected, cancel the suspension operation associated with the named pipe and release the system resources corresponding to the named pipe; If the connection times out, re-establish the connection between the named pipe and the client. If the connection fails, cancel the suspension operation associated with the named pipe and release the system resources corresponding to the named pipe.
5. The method according to claim 1, wherein creating the named pipe corresponding to the client includes: Receive connection requests sent by clients; Based on the connection request, obtain the digital signature of the client that initiated the connection request; Verify the digital signature; In response to the digital signature meeting preset conditions, a named pipe corresponding to the client is created.
6. The method according to claim 3, wherein processing the service data transmitted by the named pipe to obtain a processing result includes: The business data transmitted by the named pipe is stored in a preset message container; Based on preset reading rules, the target data to be interacted is determined from the business data stored in the preset message container; The target receiving end corresponding to the target data is determined, and the target data is sent to the target receiving end; the target receiving end is the client or the server. The target data is processed based on the target receiving end to obtain the processing result.
7. The method according to claim 6, wherein determining the target receiving end corresponding to the target data includes: The target data is parsed to determine the receiver identifier corresponding to the target data; Based on the receiver identifier, a matching target receiver is searched in the client container; wherein, the client container stores the identifiers of each client that has established a connection with the server and the corresponding named pipes.
8. A communication architecture, said architecture comprising a server and at least one client; wherein, The server is used for: Create a named pipe for the client; The named pipe is associated with a target port, and the pipe event of the named pipe is obtained based on the target port; the pipe event is obtained based on the operation completion response obtained from the target port. Based on the event type corresponding to the pipeline event, execute the target action corresponding to the event type.
9. An electronic device, comprising: At least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the following operations: Create a named pipe for the client; The named pipe is associated with a target port, and the pipe event of the named pipe is obtained based on the target port; the pipe event is obtained based on the operation completion response obtained from the target port. Based on the event type corresponding to the pipeline event, execute the target action corresponding to the event type.
10. A non-transitory computer-readable storage medium storing computer instructions for causing a computer acting as a server to perform the following operations: Create a named pipe for the client; The named pipe is associated with a target port, and the pipe event of the named pipe is obtained based on the target port; the pipe event is obtained based on the operation completion response obtained from the target port. Based on the event type corresponding to the pipeline event, execute the target action corresponding to the event type.