A data communication method, device, terminal equipment and storage medium

Through the combination of the IOCP model and virtual containers, the problem of low thread switching efficiency when the server processes multiple client concurrent requests is solved, and more efficient processing efficiency is achieved.

CN111338747BActive Publication Date: 2024-08-27VISIONVERA INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010081798.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-02-06
Publication Date
2024-08-27
Estimated Expiration
2040-02-06

AI Technical Summary

Technical Problem

When existing servers handle concurrent requests from multiple clients, they need to frequently switch threads, resulting in low processing efficiency.

Method used

The business request of the terminal device is received through the pre-established IOCP model, and the request is transmitted to the worker thread for processing through the connection channel in the virtual container. After obtaining the execution result, it is returned to the virtual container, and finally the result is returned to the terminal device through the IOCP model. Avoid switching threads frequently.

Benefits of technology

It improves the processing efficiency of the server when processing concurrent requests from multiple threads and reduces the work pressure of the server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111338747B
    Figure CN111338747B
Patent Text Reader

Abstract

The embodiments of the present invention provide a data communication method, apparatus, terminal device and storage medium, including: receiving a service request sent by a terminal device through a pre-established IOCP model; transmitting the service request to a work thread through a connection channel in a pre-established virtual container corresponding to the terminal device, so that the work thread executes an operation corresponding to the service request and obtains an execution result; returning the execution result to the virtual container corresponding to the terminal device; returning the execution result in the virtual container to the terminal device through the pre-established IOCP model. By establishing an IOCP model, the embodiments of the present invention do not need to frequently switch between threads when processing concurrency issues of multiple threads, thereby improving the processing efficiency of the server.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data communication method, device, terminal equipment and storage medium. Background Art

[0002] With the rapid development of network technology, two-way communications such as video conferencing and video teaching have become widely popular in users' lives, work, and study.

[0003] Servers and clients mostly use network communication protocols such as TCP, UDP, SRT, RTSP and other transmission protocol frameworks for data communication. After each client accesses, the server must start a new thread to communicate with the client. In this way, as many threads as there are clients, the system must switch between all threads because these threads need to be processed. If the concurrency problem of multiple threads is handled at the same time, the server's processing efficiency will be low if the above processing method is used. Summary of the invention

[0004] In view of the above problems, embodiments of the present invention are proposed to provide a data communication method, apparatus, terminal device and storage medium that overcome the above problems or at least partially solve the above problems.

[0005] In a first aspect, an embodiment of the present invention provides a data communication method, applied to a server, the method comprising:

[0006] Receive service requests sent by terminal devices through the pre-established IOCP model;

[0007] Transmitting the service request to a work thread through a connection channel in a pre-established virtual container, so that the work thread executes an operation corresponding to the service request and obtains an execution result, wherein the virtual container is set corresponding to the terminal device;

[0008] Returning the execution result to the virtual container corresponding to the terminal device;

[0009] The execution result in the virtual container is returned to the terminal device through the pre-established IOCP model.

[0010] Optionally, the receiving a service request sent by a terminal device includes:

[0011] Receiving a socket request sent by the terminal device through an upper-layer network transmission protocol, wherein the socket request includes a protocol type of the upper-layer network transmission protocol;

[0012] Correspondingly,

[0013] The returning the execution result in the virtual container to the terminal device through the pre-established IOCP model includes:

[0014] Through the pre-established IOCP model, the execution result in the virtual container is returned to the terminal device using an upper-layer network transmission protocol corresponding to the protocol type of the upper-layer network transmission protocol.

[0015] Optionally, the working thread includes at least a receiving sub-thread and a sending sub-thread.

[0016] The service request is transmitted to the work thread through the connection channel in the pre-established virtual container, so that the work thread executes the operation corresponding to the service request and obtains the execution result, wherein the virtual container is set corresponding to the terminal device, including:

[0017] Transmitting the service request to the receiving sub-thread through the connection channel in the pre-established virtual container, so that the receiving sub-thread executes the operation corresponding to the service request in the order of the received service requests and generates the execution result, wherein the virtual container is set corresponding to the terminal device;

[0018] The execution result is transmitted to the sending sub-thread.

[0019] Optionally, returning the execution result to a virtual container corresponding to the terminal device includes:

[0020] The execution results in the sending sub-thread are returned to the virtual container corresponding to the terminal device in sequence through the connection channel.

[0021] Optionally, the upper layer network transmission protocol includes at least TCP, UDP, SRT or RTSP.

[0022] In a second aspect, an embodiment of the present invention provides a data communication device, applied to a server, the device comprising:

[0023] The receiving module is used to receive the service request sent by the terminal device through the pre-established IOCP model;

[0024] a transmission module, configured to transmit the service request to a work thread through a connection channel in a pre-established virtual container, so that the work thread executes an operation corresponding to the service request and obtains an execution result, wherein the virtual container is set corresponding to the terminal device;

[0025] A returning module, used for returning the execution result to the virtual container corresponding to the terminal device;

[0026] The sending module is used to return the execution result in the virtual container to the terminal device through the pre-established IOCP model.

[0027] Optionally, the receiving module is specifically used to:

[0028] Receiving a socket request sent by the terminal device through an upper-layer network transmission protocol, wherein the socket request includes a protocol type of the upper-layer network transmission protocol;

[0029] Correspondingly,

[0030] The sending module is specifically used for:

[0031] Through the pre-established IOCP model, the execution result in the virtual container is returned to the terminal device using an upper-layer network transmission protocol corresponding to the protocol type of the upper-layer network transmission protocol.

[0032] Optionally, the working thread includes at least a receiving sub-thread and a sending sub-thread.

[0033] The transmission module is specifically used for:

[0034] Transmitting the service request to the receiving sub-thread through the connection channel in the pre-established virtual container, so that the receiving sub-thread executes the operation corresponding to the service request in the order of the received service requests and generates the execution result, wherein the virtual container is set corresponding to the terminal device;

[0035] The execution result is transmitted to the sending sub-thread.

[0036] Optionally, the return module is specifically used to:

[0037] The execution results in the sending sub-thread are returned to the virtual container corresponding to the terminal device in sequence through the connection channel.

[0038] Optionally, the upper layer network transmission protocol includes at least TCP, UDP, SRT or RTSP.

[0039] In a third aspect, an embodiment of the present invention provides a terminal device, including: at least one processor and a memory;

[0040] The memory stores a computer program; and the at least one processor executes the computer program stored in the memory to implement the data communication method provided in the first aspect.

[0041] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed, the data communication method provided in the first aspect is implemented.

[0042] The technical solution provided by the embodiment of the present invention is applied to a server, including: receiving a service request sent by a terminal device through a pre-established IOCP model; transmitting the service request to a work thread through a connection channel in a pre-established virtual container corresponding to the terminal device, so that the work thread executes an operation corresponding to the service request and obtains an execution result; returning the execution result to the virtual container corresponding to the terminal device; returning the execution result in the virtual container to the terminal device through the pre-established IOCP model. By establishing an IOCP model, the embodiment of the present invention does not need to frequently switch between threads when processing concurrency issues of multiple threads, thereby improving the processing efficiency of the server. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 is a flow chart of steps of an embodiment of a data communication method of the present invention;

[0044] Figure 2 is a flowchart of another data communication method embodiment of the present invention;

[0045] Figure 3 is a flowchart of steps of another data communication method embodiment of the present invention;

[0046] Figure 4 is a flowchart of steps of another data communication method embodiment of the present invention;

[0047] Figure 5 is a flowchart of another data communication method embodiment of the present invention;

[0048] Figure 6 is a structural block diagram of an embodiment of a data communication device of the present invention;

[0049] Figure 7 It is a structural schematic diagram of a terminal device of the present invention. DETAILED DESCRIPTION

[0050] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0051] The glossary is explained as follows:

[0052] TCP / IP protocol: Transmission Control Protocol / Internet Protocol, refers to a protocol suite that can realize information transmission between multiple different networks. TCP / IP protocol does not only refer to TCP and IP protocols, but also refers to a protocol suite composed of FTP, SMTP, TCP, UDP, IP and other protocols. It is called TCP / IP protocol because TCP and IP are the most representative in TCP / IP protocol.

[0053] UDP / IP protocol: User Datagram Protocol, User Datagram Protocol, UDP provides a method for applications to send encapsulated IP datagrams without establishing a connection

[0054] SRT protocol: Secure Reliable Transport, is a new generation of low-latency video transmission protocol. It is an open source, free and flexible specification. Its performance is as good as that of dedicated protocols, and it can work between products produced by different manufacturers.

[0055] RTSP protocol: Real Time Streaming Protocol, real-time streaming transmission protocol, is an application layer protocol in the TCP / IP protocol system, an IETF RFC standard submitted by Columbia University, Netscape and RealNetworks. This protocol defines how one-to-many applications can effectively transmit multimedia data over IP networks. RTSP is located above RTP and RTCP in terms of architecture, and it uses TCP or UDP to complete data transmission.

[0056] IOCP: I / O Completion Port, often called I / O completion port. The IOCP model is a communication model, a technology suitable for high-load servers that can control concurrent execution. In layman's terms, it is a model for efficiently processing data exchange between many clients. Or it can be said that it is a model that can perform asynchronous I / O operations; "Completion" in IOCP (i.e., completion port) means that the system will be notified only after the network I / O operation is "completed" that the data from the network has been received. This allows the application to do other things during I / O transmission. The IOCP network communication model is currently the most widely used underlying framework for network communication that supports large concurrency and high load.

[0057] Layer 3 upper layer protocol: This refers to the protocol that implements related features by interacting with the layer 3 bottom layer, such as TCP three-way handshake guarantee and UDP direct transmission.

[0058] In reality, most network communication protocols such as TCP, UDP, SRT, RTSP and other protocols are mostly transmission protocol frameworks. These protocols solve transmission-related problems and can be defined as three-layer upper-layer protocols.

[0059] The third layer underlying protocol: This refers to the protocol framework that directly interacts with I / O and handles high-performance concurrency and fast real-time transmission.

[0060] The IOCP model can be vaguely understood as the bottom layer protocol mode in the three layers, which receives data through the IOCP mode and then transmits it to the upper layer protocol in the three layers. An additional layer is added between the upper layer protocol of the three layers and the bottom layer protocol I / O, that is, the IOCP model is added, which combines the upper layer protocol of the three layers with the bottom layer protocol of the three layers, realizes the layered processing of data communication, and retains the advantages and strengths of both, and seamlessly connects the network communication protocol and the IOCP model.

[0061] Reference Figure 1 , shows a flow chart of steps of a data communication method embodiment of the present invention, which can be applied in a server and may specifically include the following steps:

[0062] S101, receiving a service request sent by a terminal device through a pre-established IOCP model;

[0063] Specifically, on the server side, an IOCP model is pre-established, and service requests sent by multiple Internet terminal devices can be received simultaneously through multiple asynchronous I / Os, wherein each service request includes data information and a protocol type of a network communication protocol.

[0064] In practice, each data information may be the information obtained by an Internet terminal encapsulating the original data packet using the above-mentioned Internet network communication protocol. The Internet network communication protocol, i.e., the upper-layer network transmission protocol, may be but is not limited to the following communication protocols: TCP / IP protocol, UDP / IP protocol, SRT protocol or RTSP protocol.

[0065] The data information in this embodiment can be but is not limited to the following information: login information, audio and video stream data information, command information, etc.

[0066] S102, transmitting the service request to a work thread through a connection channel in a pre-established virtual container, so that the work thread executes an operation corresponding to the service request and obtains an execution result, wherein the virtual container is set corresponding to the terminal device;

[0067] Specifically, a corresponding virtual container is pre-established on the server for each terminal device, i.e., an Internet terminal, and a corresponding connection channel is set for each virtual container, wherein the virtual container is used to store various parameters carried in the service requests sent by each terminal device, including but not limited to data information, endpoint information, and protocol type of the network communication protocol.

[0068] When the server receives a service request sent by a terminal device through the IOCP interface, it stores the service request in a virtual container corresponding to the terminal device, and transmits the service request to the working thread for processing through the connection channel in the virtual container. The working thread executes the operation corresponding to the service request and obtains the execution result. In addition, during this execution process, the endpoint information corresponding to the terminal device is carried.

[0069] S103, returning the execution result to the virtual container corresponding to the terminal device;

[0070] The server returns the execution result to the virtual container corresponding to the terminal device through the connection channel, that is, according to the endpoint information, the server returns the execution result to the virtual container corresponding to the endpoint information.

[0071] S104: Return the execution result in the virtual container to the terminal device through the pre-established IOCP model.

[0072] Specifically, the server sends the execution result in the virtual container to the terminal device through the I / O interface of the IOCP model according to the endpoint information of the terminal device, namely, the IP address and the port number.

[0073] Exemplarily, the server receives a login request sent by terminal device A and a live broadcast start request sent by terminal device B through a pre-established IOCP model, and temporarily stores the two requests in the IOCP model;

[0074] By pre-setting a virtual container A corresponding to terminal device A and a virtual container B corresponding to terminal device B, temporarily storing the login request in virtual container A, parsing the login request to obtain login data, user information, endpoint information, network communication protocol type, etc., temporarily storing the live broadcast start request in virtual container B, parsing the live broadcast start request to obtain live broadcast data, endpoint information, network communication protocol type, etc.;

[0075] The login request is sent to the working thread through the connection channel A in the virtual container A, and the live broadcast start request is also sent to the working thread through the connection channel B in the virtual container B. In this way, the working thread first receives the login request and then receives the live broadcast start request, processes them in the order in which they are received, and obtains the execution result, and returns the execution result to the corresponding virtual container through the corresponding connection channel, and then the virtual container sends it to the corresponding terminal device through the IOCP model according to the stored endpoint information. In this process, the business requests of each terminal device are received through the IOCP model, and there is no need to frequently switch between threads, which improves the server processing efficiency and reduces the workload of the server.

[0076] The data communication method provided by the embodiment of the present invention receives a service request sent by a terminal device through a pre-established IOCP model; transmits the service request to a working thread through a connection channel in a pre-established virtual container corresponding to the terminal device, so that the working thread executes an operation corresponding to the service request and obtains an execution result; returns the execution result to the virtual container corresponding to the terminal device; and returns the execution result in the virtual container to the terminal device through the pre-established IOCP model. By establishing an IOCP model, the embodiment of the present invention does not need to frequently switch between threads when processing concurrency issues of multiple threads, thereby improving the processing efficiency of the server.

[0077] Another embodiment of the present invention further supplements the method provided by the above embodiment.

[0078] like Figure 2 FIG. 1 is a flowchart showing another data communication method embodiment of the present invention, wherein the method further comprises:

[0079] S201, receiving a socket request sent by the terminal device through an upper-layer network transmission protocol through a pre-established IOCP model, wherein the socket request includes a protocol type of the upper-layer network transmission protocol;

[0080] Specifically, the server and the terminal device establish a socket connection, and the terminal device sends a service request to the server through the socket, wherein the socket can be included in the Internet communication protocol, which can be understood as an interface for interaction between the application layer protocol and the transport layer protocol, which can be used to distinguish network communications and connections between different application processes.

[0081] S202, transmitting the service request to a work thread through a connection channel in a pre-established virtual container, so that the work thread executes an operation corresponding to the service request and obtains an execution result, wherein the virtual container is set corresponding to the terminal device;

[0082] S203, returning the execution result to the virtual container corresponding to the terminal device;

[0083] S204: Using the pre-established IOCP model, returning the execution result in the virtual container to the terminal device using an upper-layer network transmission protocol corresponding to the protocol type of the upper-layer network transmission protocol.

[0084] Correspondingly, the terminal device sends a service request to the server using a certain type of network communication protocol, and the server returns the execution result to the terminal device using the corresponding network communication protocol.

[0085] For example, if a terminal device sends a service request to the server via TCP / IP, the server receives the service requests sent by each terminal device through the pre-established IOCP model, executes the service request, obtains the execution result, and returns the execution result to the terminal device via TCP / IP, thereby achieving seamless integration of the IOCP model with existing communication transmission protocols.

[0086] It should be noted that existing communication transmission protocols include TCP / IP and UDP / IP, but are not limited thereto.

[0087] Since step S202 to step S203, Figure 1 Steps S102 to S103 in the illustrated embodiment are the same. Figure 1 Steps S102 to S103 have been described in detail in the specification, so steps S202 to S203 will not be described again here.

[0088] like Figure 3 FIG. 1 is a flowchart showing another data communication method embodiment of the present invention, wherein the working thread at least includes a receiving sub-thread and a sending sub-thread, and step S102 specifically includes:

[0089] S1021. Transmitting the service request to the receiving sub-thread through the connection channel in the pre-established virtual container, so that the receiving sub-thread executes the operation corresponding to the service request in the order of the received service requests and generates the execution result, wherein the virtual container is set corresponding to the terminal device;

[0090] S1022. Transmit the execution result to the sending sub-thread.

[0091] Specifically, the working thread at least monitors the sub-thread, receives the sub-thread and sends the sub-thread. The monitoring sub-thread is used to monitor whether each terminal device sends a service request. The receiving sub-thread is used to store each service request according to the order in which the service requests are received, and execute them in the order in which they are stored, and obtain the execution result; the execution result is stored in the sending sub-thread, that is, after the receiving sub-thread receives the service request and executes it, the execution result is stored in the sending sub-thread, waiting for the sending sub-thread to send it.

[0092] like Figure 4 FIG. 1 is a flowchart showing another data communication method embodiment of the present invention, wherein the data communication method comprises:

[0093] S401. Receive a socket request sent by the terminal device through an upper-layer network transmission protocol through a pre-established IOCP model, wherein the socket request includes a protocol type of the upper-layer network transmission protocol.

[0094] S402, transmitting the service request to the receiving sub-thread through the pre-established connection channel in the virtual container corresponding to the terminal device, so that the receiving sub-thread executes the operations corresponding to the service requests in the order of the received service requests, and generates the execution result;

[0095] S403, transmitting the execution result to the sending sub-thread;

[0096] S404: returning the execution results in the sending sub-thread to the virtual container corresponding to the terminal device in sequence through the connection channel;

[0097] Specifically, when the receiving sub-thread receives a business request and executes the operation corresponding to the business request, obtains the execution result, and stores the execution result in the sending sub-thread, the sending sub-thread returns the execution result to the virtual container corresponding to the terminal device through the connection channel in the order of the execution results. That is, in the process of each thread executing the operation, it carries the endpoint information of the terminal device, and returns the execution result to the virtual container corresponding to the endpoint information according to the endpoint information.

[0098] S405: Using the pre-established IOCP model, the execution result in the virtual container is returned to the terminal device using an upper-layer network transmission protocol corresponding to the protocol type of the upper-layer network transmission protocol.

[0099] Due to step S401, step S402, step S403 and step 404, Figure 2 Steps S201, S202 and S404 in the illustrated embodiment, and Figure 3Steps S1021 and S1022 in the illustrated embodiment are the same. Figure 2 Steps S201, S202 and S404 have been described in detail. Figure 3 Steps S1021-S1022 in FIG. 4 are described in detail, and therefore, step S401, step S402, step S403 and step S404 are not described in detail here.

[0100] like Figure 5 FIG. 1 is a flowchart showing another data communication method embodiment of the present invention, wherein the data communication method comprises:

[0101] S501. Sockets corresponding to different clients, i.e., terminals, are created on the server, wherein the socket contains the protocol type of the network communication protocol, wherein each terminal may use a different specific network transmission protocol or the same specific transmission protocol, and a socket of a specific network transmission protocol A is created on the server side, wherein the specific network transmission protocol is the upper layer network transmission protocol of the third layer;

[0102] S502: On the server side, create an IOCP model (I / O completion interface).

[0103] S503, using the monitoring thread in the IOCP model to monitor the messages of each client;

[0104] S504: On the server side, create a virtual container SocketUserToken corresponding to the client, and this virtual container contains the connection channel Connection corresponding to the client;

[0105] S505. The server receives a service request sent by the client through the IOCP model, wherein the service request includes the protocol type of the upper-layer network communication protocol and the endpoint information of the client, such as: login, registration, videophone start, videophone end, live broadcast start, live broadcast end, request for meeting or raise hand to speak, etc.;

[0106] The server stores the data carried in the received service request in a virtual container corresponding to the client, namely SocketUserToken, and can parse the data packet carried in the received service request in this virtual container, such as unpacking.

[0107] S506, transmitting the service request to the receiving sub-thread through the connection channel Connection, and the receiving sub-thread executes the operations corresponding to the service requests in the order of the received service requests to obtain the execution result;

[0108] S507, transmitting the execution result to the sending sub-thread, and returning the execution result in the sending sub-thread to the virtual container corresponding to the terminal device through the connection channel Connection in sequence;

[0109] S508: According to the endpoint information stored in the virtual container corresponding to the terminal device, the server returns the processed data to the corresponding terminal device through the IOCP interface using the corresponding network communication protocol.

[0110] The data communication method provided by the embodiment of the present invention receives a service request sent by a terminal device through a pre-established IOCP model; transmits the service request to a working thread through a connection channel in a pre-established virtual container corresponding to the terminal device, so that the working thread executes an operation corresponding to the service request and obtains an execution result; returns the execution result to the virtual container corresponding to the terminal device; and returns the execution result in the virtual container to the terminal device through the pre-established IOCP model. By establishing an IOCP model, the embodiment of the present invention does not need to frequently switch between threads when processing concurrency issues of multiple threads, thereby improving the processing efficiency of the server.

[0111] Another embodiment of the present invention provides a data communication device, which is used to execute the data communication method provided in the above embodiment.

[0112] Reference Figure 6 , shows a structural block diagram of an embodiment of a data communication device of the present invention, which is applied to a server, and the device includes: a receiving module 601, a transmission module 602, a return module 603 and a sending module 604, wherein:

[0113] The receiving module 601 is used to receive a service request sent by a terminal device through a pre-established IOCP model;

[0114] The transmission module 602 is used to transmit the service request to the work thread through the connection channel in the pre-established virtual container, so that the work thread executes the operation corresponding to the service request and obtains the execution result, wherein the virtual container is set corresponding to the terminal device;

[0115] The returning module 603 is used to return the execution result to the virtual container corresponding to the terminal device;

[0116] The sending module 604 is used to return the execution result in the virtual container to the terminal device through the pre-established IOCP model.

[0117] The data communication device provided by the embodiment of the present invention receives a service request sent by a terminal device through a pre-established IOCP model; transmits the service request to a working thread through a connection channel in a pre-established virtual container corresponding to the terminal device, so that the working thread executes an operation corresponding to the service request and obtains an execution result; returns the execution result to the virtual container corresponding to the terminal device; and returns the execution result in the virtual container to the terminal device through the pre-established IOCP model. By establishing an IOCP model, the embodiment of the present invention does not need to frequently switch between threads when processing concurrency issues of multiple threads, thereby improving the processing efficiency of the server.

[0118] Another embodiment of the present invention further supplements the device provided in the above embodiment.

[0119] Optionally, the receiving module 601 is specifically used for:

[0120] Receiving a socket request sent by the terminal device through an upper-layer network transmission protocol, wherein the socket request includes a protocol type of the upper-layer network transmission protocol;

[0121] Correspondingly,

[0122] The sending module 604 is specifically used for:

[0123] Through the pre-established IOCP model, the execution result in the virtual container is returned to the terminal device using an upper-layer network transmission protocol corresponding to the protocol type of the upper-layer network transmission protocol.

[0124] Optionally, the working thread includes at least a receiving sub-thread and a sending sub-thread.

[0125] The transmission module 602 is specifically used for:

[0126] Transmitting the service request to the receiving sub-thread through the connection channel in the pre-established virtual container, so that the receiving sub-thread executes the operation corresponding to the service request in the order of the received service requests and generates the execution result, wherein the virtual container is set corresponding to the terminal device;

[0127] The execution result is transmitted to the sending sub-thread.

[0128] Optionally, the returning module 603 is specifically used for:

[0129] The execution results in the sending sub-thread are returned to the virtual container corresponding to the terminal device in sequence through the connection channel.

[0130] Optionally, the upper layer network transmission protocol includes at least TCP protocol, UDP protocol, SRT protocol or RTSP protocol.

[0131] It should be noted that each implementable method in this embodiment may be implemented separately, or may be implemented in combination in any combination without conflict, and this application is not limited thereto.

[0132] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0133] The data communication device provided by the embodiment of the present invention receives a service request sent by a terminal device through a pre-established IOCP model; transmits the service request to a working thread through a connection channel in a pre-established virtual container corresponding to the terminal device, so that the working thread executes an operation corresponding to the service request and obtains an execution result; returns the execution result to the virtual container corresponding to the terminal device; and returns the execution result in the virtual container to the terminal device through the pre-established IOCP model. By establishing an IOCP model, the embodiment of the present invention does not need to frequently switch between threads when processing concurrency issues of multiple threads, thereby improving the processing efficiency of the server.

[0134] Yet another embodiment of the present invention provides a terminal device for executing the data communication method provided in the above embodiment.

[0135] Figure 7 is a schematic diagram of the structure of a terminal device of the present invention, such as Figure 7 As shown, the electronic device includes: at least one processor 701 and a memory 702;

[0136] The memory stores a computer program; and the at least one processor executes the computer program stored in the memory to implement the data communication method provided in the above embodiment.

[0137] The terminal device provided in this embodiment receives a service request sent by the terminal device through a pre-established IOCP model; transmits the service request to the working thread through a pre-established connection channel in a virtual container corresponding to the terminal device, so that the working thread executes an operation corresponding to the service request and obtains an execution result; returns the execution result to the virtual container corresponding to the terminal device; and returns the execution result in the virtual container to the terminal device through the pre-established IOCP model. By establishing an IOCP model, the embodiment of the present invention does not need to frequently switch between threads when processing concurrency issues of multiple threads, thereby improving the processing efficiency of the server.

[0138] Yet another embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed, the data communication method provided in any of the above embodiments is implemented.

[0139] According to the computer-readable storage medium of the present embodiment, a service request sent by a terminal device is received through a pre-established IOCP model; the service request is transmitted to a working thread through a connection channel in a pre-established virtual container corresponding to the terminal device, so that the working thread executes an operation corresponding to the service request and obtains an execution result; the execution result is returned to the virtual container corresponding to the terminal device; and the execution result in the virtual container is returned to the terminal device through the pre-established IOCP model. By establishing an IOCP model, the embodiment of the present invention does not need to frequently switch between threads when dealing with concurrency issues of multiple threads, thereby improving the processing efficiency of the server.

[0140] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0141] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0142] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0143] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0144] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable terminal device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0145] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0146] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0147] The data communication method and the data communication device provided by the present invention are introduced in detail above. The principle and implementation mode of the present invention are explained by using specific examples in this article. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation mode and the scope of application. In summary, the content of this specification should not be understood as limiting the present invention.

Claims

1. A data communication method, characterized in that: Applied to a server, the method comprises: Receive service requests sent by terminal devices through the pre-established IOCP model; The service request is transmitted to the work thread through a connection channel in a pre-established virtual container, so that the work thread executes an operation corresponding to the service request and obtains an execution result, wherein the virtual container is set corresponding to the terminal device; the virtual container is used to store parameters carried in the service request sent by the terminal device, and the parameters include: data information, endpoint information and protocol type of the network communication protocol; Returning the execution result to the virtual container corresponding to the terminal device includes: the server returns the execution result to the virtual container corresponding to the terminal device through the connection channel according to the endpoint information; The method of returning the execution result in the virtual container to the terminal device through the pre-established IOCP model comprises: the server sending the execution result in the virtual container to the terminal device through the I / O interface of the IOCP model according to the endpoint information of the terminal device, i.e., the IP address and the port number.

2. The method according to claim 1, characterized in that The receiving a service request sent by a terminal device includes: Receiving a socket request sent by the terminal device through an upper-layer network transmission protocol, wherein the socket request includes a protocol type of the upper-layer network transmission protocol; Correspondingly, The returning the execution result in the virtual container to the terminal device through the pre-established IOCP model includes: Through the pre-established IOCP model, the execution result in the virtual container is returned to the terminal device using an upper-layer network transmission protocol corresponding to the protocol type of the upper-layer network transmission protocol.

3. The method according to claim 2, characterized in that The working thread at least includes a receiving sub-thread and a sending sub-thread. The service request is transmitted to the work thread through the connection channel in the pre-established virtual container, so that the work thread executes the operation corresponding to the service request and obtains the execution result, wherein the virtual container is set corresponding to the terminal device, including: Transmitting the service request to the receiving sub-thread through the connection channel in the pre-established virtual container, so that the receiving sub-thread executes the operations corresponding to the service request in the order of the received service requests and generates the execution result; The execution result is transmitted to the sending sub-thread.

4. The method according to claim 3, characterized in that The returning the execution result to the virtual container corresponding to the terminal device includes: The execution results in the sending sub-thread are returned to the virtual container corresponding to the terminal device in sequence through the connection channel.

5. The method according to claim 2, characterized in that: The upper layer network transmission protocol includes TCP, UDP, SRT or RTSP.

6. A data communication device, characterized in that: Applied to a server, the device comprises: The receiving module is used to receive the service request sent by the terminal device through the pre-established IOCP model; A transmission module, used to transmit the service request to the work thread through a connection channel in a pre-established virtual container, so that the work thread executes the operation corresponding to the service request and obtains the execution result, wherein the virtual container is set corresponding to the terminal device; the virtual container is used to store parameters carried in the service request sent by the terminal device, and the parameters include: data information, endpoint information and protocol type of the network communication protocol; A returning module, used for returning the execution result to the virtual container corresponding to the terminal device, comprising: the server returning the execution result to the virtual container corresponding to the terminal device through the connection channel according to the endpoint information; The sending module is used to return the execution result in the virtual container to the terminal device through the pre-established IOCP model, including: the server sends the execution result in the virtual container to the terminal device through the I / O interface of the IOCP model according to the endpoint information of the terminal device, that is, the IP address and port number.

7. The device according to claim 6, characterized in that The receiving module is specifically used for: Receiving a socket request sent by the terminal device through an upper-layer network transmission protocol, wherein the socket request includes a protocol type of the upper-layer network transmission protocol; Correspondingly, The sending module is specifically used for: Through the pre-established IOCP model, the execution result in the virtual container is returned to the terminal device using an upper-layer network transmission protocol corresponding to the protocol type of the upper-layer network transmission protocol.

8. The device according to claim 6, characterized in that The working thread at least includes a receiving sub-thread and a sending sub-thread. The transmission module is specifically used for: Transmitting the service request to the receiving sub-thread through the connection channel in the pre-established virtual container, so that the receiving sub-thread executes the operations corresponding to the service request in the order of the received service requests and generates the execution result; The execution result is transmitted to the sending sub-thread.

9. A terminal device, characterized in that: include: at least one processor and memory; The memory stores a computer program; The at least one processor executes the computer program stored in the memory to implement the data communication method according to any one of claims 1 to 5.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the data communication method according to any one of claims 1 to 5 is implemented.