Data transmission method and device, storage medium and electronic equipment

文档序号:510396 发布日期:2021-05-28 浏览:3次 中文

阅读说明:本技术 数据传输方法和装置、存储介质及电子设备 (Data transmission method and device, storage medium and electronic equipment ) 是由 吴惠敏 于 2021-02-02 设计创作,主要内容包括:本发明公开了一种数据传输方法和装置、存储介质及电子设备。其中,该方法包括:采用接收端通过接口接收发送端发送的数据传输指令,其中,接收端和发送端建立通信连接Link,数据传输指令用于传输数据;根据连接Link当前的状态,确定接收端是否接收数据的方式,达到了建立连接的两端,无需额外的中介系统,连接两端可独立调度,每端都支持多线程上下文,并发进行数据通信,具有可靠特性和异步特性,进而解决了现有技术中,连接两端数据的传输需要中介系统,导致数据传输效率低的技术问题。(The invention discloses a data transmission method and device, a storage medium and electronic equipment. Wherein, the method comprises the following steps: receiving a data transmission instruction sent by a sending end through an interface by adopting a receiving end, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for transmitting data; the method for determining whether the receiving end receives the data according to the current state of the Link connection achieves two ends for establishing the connection, does not need an additional intermediary system, can independently schedule the two ends for connection, supports multi-thread context at each end, concurrently carries out data communication, has reliable characteristic and asynchronous characteristic, and further solves the technical problem that the transmission of the data at the two ends for connection needs the intermediary system and causes low data transmission efficiency in the prior art.)

1. A method of data transmission, comprising:

a receiving end receives a data transmission instruction sent by a sending end through an interface, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for transmitting data;

and determining whether the receiving end receives the data or not according to the current state of the connection Link.

2. The method according to claim 1, wherein the determining whether the receiving end receives the data according to the current state of the connection Link comprises:

under the condition that the current state of the Link is an idle state, the receiving end receives the data sent by the sending end;

and under the condition that the current state of the connection Link is a non-idle state, putting the data sent by the sending end into a queue for queuing.

3. The method according to claim 2, wherein the receiving end receives the data sent by the sending end when the current state of the connection Link is an idle state, and the method includes:

and setting the current state of the Link to be a locking state, and sending the data in a transmission protocol buffer area by the sending end.

4. The method according to claim 3, wherein in a case that the current state of the connection Link is an idle state, the receiving end receives the data sent by the sending end, including:

and setting the current state of the Link to be a locking state, and awakening and sending the waiting data by the sending end.

5. The method of claim 4, wherein the sending end wakes up and sends the waiting data, and comprises:

and when the waiting data is positioned in the transfer protocol buffer zone or the waiting time of the waiting data is longer than a first preset time, the sending end wakes up and sends the waiting data.

6. The method of claim 4, wherein the sending end wakes up and sends the waiting data, and comprises:

and under the condition that the waiting time of the waiting data is longer than a second time, switching the connection Link into a cache waiting mode until the connection Link is awakened.

7. The method according to claim 2, wherein the receiving end receives the data sent by the sending end when the current state of the connection Link is an idle state, and the method includes:

in the process that the receiving end receives the data sent by the sending end, the connection Link is allowed to be preempted and switched to a receiving suspension state to wait to be awakened again, and information is directly taken from the suspension cache queue or the receiving waiting state is entered again.

8. The method according to claim 2, wherein in a case that the current state of the connection Link is an idle state, after the receiving end receives the data sent by the sending end, the method comprises:

the receiving end sends a response message to the sending end, wherein the response message is used for indicating that the data reception is finished;

and queuing the response information under the condition that the connection Link is in a non-idle state, and sending the response information when the connection Link is idle.

9. A method of data transmission, comprising:

a sending end sends a data transmission instruction to a receiving end through an interface, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for sending data;

and determining whether the sending end sends the data or not according to the current state of the Link.

10. A data transmission apparatus, comprising:

the receiving unit is used for receiving a data transmission instruction sent by a sending end through an interface by a receiving end, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for transmitting data;

and the determining unit is used for determining whether the receiving end receives the data or not according to the current state of the connection Link.

11. A computer-readable storage medium, comprising a stored program, wherein the program when executed performs the method of any of claims 1 to 9.

12. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method of any of claims 1 to 9 by means of the computer program.

Technical Field

The present invention relates to the field of communications technologies, and in particular, to a data transmission method and apparatus, a storage medium, and an electronic device.

Background

In a system composed of multiple processors, the data transmission between the processors is usually realized by various buses and point-to-point transmission. Bus-based transmission architectures require bus arbitration among the processors since the multiple processors share a bus. Bus arbitration is not conducive to real-time processing because after an application submits a bus application, it is necessary to wait for the bus arbitration mechanism to grant the bus arbitration mechanism before occupying the bus for data transmission, and the waiting time is unpredictable for the application.

Different from a bus transmission mode, the transmission initiation time of a point-to-point transmission mode is completely controlled by an application program, so that the transmission time corresponding program can be completely predicted, the time between data exchange and data processing can be reasonably budgeted by the application program, and the application program meets the application requirement of real-time processing. Point-to-point transmission has found application in the field of real-time processing. However, point-to-point transmission requires corresponding setting of a transmission mode and a transmission length parameter at a transmitting end and a receiving end, and requires the same setting at the transmitting end and the receiving end, which is predetermined and cannot be changed in real time.

In the prior art, data transmission usually depends on characteristics of a TCP transmission protocol, effects of the characteristics are only effective in a protocol stack of a point-to-point connection, and the effects cannot be extended to application logic based on the protocol stack, typically, a reply message of a command can only confirm that an opposite-end TCP protocol stack receives the reply message, but cannot confirm that the opposite-end application logic obtains the reply message.

In view of the above problems, no effective solution has been proposed.

Disclosure of Invention

Embodiments of the present invention provide a data transmission method and apparatus, a storage medium, and an electronic device, so as to at least solve the technical problem in the prior art that data transmission efficiency is low because an intermediary system is required for transmitting data at two ends.

According to an aspect of an embodiment of the present invention, there is provided a data transmission method, including: a receiving end receives a data transmission instruction sent by a sending end through an interface, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for transmitting data; and determining whether the receiving end receives the data or not according to the current state of the connection Link.

Optionally, the determining, according to the current state of the connection Link, whether the receiving end receives the data includes: under the condition that the current state of the Link is an idle state, the receiving end receives the data sent by the sending end; and under the condition that the current state of the connection Link is a non-idle state, putting the data sent by the sending end into a queue for queuing.

Optionally, when the current state of the Link connection is an idle state, the receiving end receives the data sent by the sending end, including: and setting the current state of the Link to be a locking state, and sending the data in a transmission protocol buffer area by the sending end.

Optionally, when the current state of the Link connection is an idle state, the receiving end receives the data sent by the sending end, including: and setting the current state of the Link to be a locking state, and awakening and sending the waiting data by the sending end.

Optionally, the waking up and sending the data waiting by the sending end includes: and when the waiting data is positioned in the transfer protocol buffer zone or the waiting time of the waiting data is longer than a first preset time, the sending end wakes up and sends the waiting data.

Optionally, the waking up and sending the data waiting by the sending end includes: and under the condition that the waiting time of the waiting data is longer than a second time, switching the connection Link into a cache waiting mode until the connection Link is awakened.

Optionally, when the current state of the Link connection is an idle state, the receiving end receives the data sent by the sending end, including: in the process that the receiving end receives the data sent by the sending end, the connection Link is allowed to be preempted and switched to a receiving suspension state to wait to be awakened again, and information is directly taken from the suspension cache queue or the receiving waiting state is entered again.

Optionally, when the current state of the connection Link is an idle state, after the receiving end receives the data sent by the sending end, the method includes: the receiving end sends a response message to the sending end, wherein the response message is used for indicating that the data reception is finished; and queuing the response information under the condition that the connection Link is in a non-idle state, and sending the response information when the connection Link is idle.

According to another aspect of the embodiments of the present invention, there is also provided a data transmission method, including: a sending end sends a data transmission instruction to the sending end through an interface, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for sending data; and determining whether the sending end sends the data or not according to the current state of the Link.

According to another aspect of the embodiments of the present invention, there is also provided a data transmission apparatus, including: the receiving unit is used for receiving a data transmission instruction sent by a sending end through an interface by a receiving end, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for transmitting data; and the determining unit is used for determining whether the receiving end receives the data or not according to the current state of the connection Link.

According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the above data transmission method when running.

According to still another aspect of the embodiments of the present invention, there is also provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the data transmission method by the computer program.

In the embodiment of the invention, a receiving end is adopted to receive a data transmission instruction sent by a sending end through an interface, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for transmitting data; the method for determining whether the receiving end receives the data according to the current state of the Link connection achieves two ends for establishing the connection, does not need an additional intermediary system, can independently schedule the two ends for connection, supports multi-thread context at each end, concurrently carries out data communication, has reliable characteristic and asynchronous characteristic, and further solves the technical problem that the transmission of the data at the two ends for connection needs the intermediary system and causes low data transmission efficiency in the prior art.

Drawings

The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:

FIG. 1 is a schematic diagram of an application environment of an alternative data transmission method according to an embodiment of the invention;

FIG. 2 is a flow chart of an alternative method of data transmission according to an embodiment of the present invention;

FIG. 3 is a flow chart of an alternative method of data transmission according to an embodiment of the present invention;

FIG. 4 is a flow chart of an alternative method of hybrid command-event communication, in accordance with embodiments of the present invention;

FIG. 5 is a flow chart of an alternative method of hybrid command-event communication, according to an embodiment of the present invention;

FIG. 6 is a flow chart of an alternative method of hybrid command-event communication, according to an embodiment of the present invention (III);

FIG. 7 is a schematic diagram of an alternative data transmission apparatus (I) according to an embodiment of the present invention;

FIG. 8 is a schematic structural diagram of an alternative data transmission apparatus (II) according to an embodiment of the present invention;

fig. 9 is a schematic structural diagram of an alternative electronic device according to an embodiment of the invention.

Detailed Description

In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.

According to an aspect of the embodiments of the present invention, a data transmission method is provided, and optionally, as an optional implementation manner, the data transmission method may be applied, but not limited, to the environment shown in fig. 1. Terminal 102, network 110, and terminal 104.

A receiving end in the terminal 102 receives a data transmission instruction sent by a sending end through an interface, wherein the receiving end and the sending end establish a communication connection Link, and the data transmission instruction is used for transmitting data; the method for determining whether the receiving end receives data or not according to the current state of the Link connection achieves the purposes that two ends of the connection are established, an additional intermediary system is not needed, the two ends of the connection can be independently scheduled, each end supports a multi-thread context, data communication is carried out concurrently, the method has the reliable characteristic and the asynchronous characteristic, and an additional protocol stack context is not needed, and further the technical problem that in the prior art, the transmission of data at two ends of the connection needs the intermediary system, so that the data transmission efficiency is low is solved.

Optionally, in this embodiment, the terminal may be a terminal device configured with a target client, and may include, but is not limited to, at least one of the following: mobile phones (such as Android phones, iOS phones, etc.), notebook computers, tablet computers, palm computers, MID (Mobile Internet Devices), PAD, desktop computers, smart televisions, etc. The target client may be a video client, an instant messaging client, a browser client, an educational client, etc. Such networks may include, but are not limited to: a wired network, a wireless network, wherein the wired network comprises: a local area network, a metropolitan area network, and a wide area network, the wireless network comprising: bluetooth, WIFI, and other networks that enable wireless communication. The server may be a single server, a server cluster composed of a plurality of servers, or a cloud server. The above is merely an example, and this is not limited in this embodiment.

Optionally, as an optional implementation manner, as shown in fig. 2, the data transmission method includes:

step S202, the receiving end receives a data transmission instruction sent by the sending end through the interface, wherein the receiving end and the sending end establish a communication connection Link, and the data transmission instruction is used for transmitting data.

Step S204, according to the current state of the Link, whether the receiving end receives the data is determined.

Optionally, the data transmission method may include, but is not limited to, a hybrid communication of data, commands, and events in a peer-to-peer, reliable, synchronous, or asynchronous mode, where the data may include, but is not limited to, commands, and events, the sending end may be a terminal, and the receiving end may be a terminal, and the data transmission method is applied to a data transmission process in multiple processors.

Optionally, in this embodiment, determining whether the receiving end receives data according to the current state of the Link may include: under the condition that the current state of the Link is an idle state, the receiving end receives data sent by the sending end; and under the condition that the current state of the Link is a non-idle state, putting the data sent by the sending end into a queue for queuing.

When the current state of the Link connection is an idle state, the receiving end receives data sent by the sending end, and the receiving end may include: and setting the current state of the Link to be a locking state, and sending the data in the transmission protocol buffer area by the sending end.

Optionally, in this embodiment, when the current state of the Link connection is an idle state, the receiving end receives data sent by the sending end, which may include: and setting the current state of the Link to be in a locking state, and awakening and sending the waiting data by the sending end.

The waking up and sending the data waiting at the sending end may include: when the waiting data is located in the transfer protocol buffer area or the waiting time of the waiting data is longer than the first preset time, the sending end wakes up and sends the waiting data.

It should be noted that, the waking up and sending the data waiting by the sending end may include: and under the condition that the waiting time of the waiting data is longer than the second time, switching the connection Link into a cache waiting mode until being awakened.

Optionally, in this embodiment, when the current state of the Link connection is an idle state, the receiving end receives data sent by the sending end, which may include: in the process that the receiving end receives the data sent by the sending end, the connection Link is allowed to be preempted and switched to a receiving suspension state to wait for being awakened again, and information is directly taken from the suspension cache queue or the receiving waiting state is entered again.

When the current state of the Link connection is an idle state, the receiving end may receive data sent by the sending end, and then: the receiving end sends a response message to the sending end, wherein the response message is used for indicating that the data receiving is finished; and queuing the response information under the condition that the connection Link is in a non-idle state, and sending the response information when the connection Link is idle.

According to the embodiment provided by the application, a receiving end is adopted to receive a data transmission instruction sent by a sending end through an interface, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for transmitting data; the method for determining whether the receiving end receives data or not according to the current state of the Link connection achieves the purposes that two ends of the connection are established, an additional intermediary system is not needed, the two ends of the connection can be independently scheduled, each end supports a multi-thread context, data communication is carried out concurrently, the method has the reliable characteristic and the asynchronous characteristic, and an additional protocol stack context is not needed, and further the technical problem that in the prior art, the transmission of data at two ends of the connection needs the intermediary system, so that the data transmission efficiency is low is solved.

Optionally, as an optional implementation manner, as shown in fig. 3, the data transmission method includes:

step S302, the sending end sends a data transmission instruction to the sending end through an interface, wherein the receiving end and the sending end establish a communication connection Link, and the data transmission instruction is used for sending data.

Step S304, determining whether the sending end sends data or not according to the current state of the Link.

According to the embodiment provided by the application, a sending end is adopted to send a data transmission instruction to the sending end through an interface, wherein a receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for sending data; the method for determining whether the receiving end receives data or not according to the current state of the Link connection achieves the purposes that two ends of the connection are established, an additional intermediary system is not needed, the two ends of the connection can be independently scheduled, each end supports a multi-thread context, data communication is carried out concurrently, the method has the reliable characteristic and the asynchronous characteristic, and an additional protocol stack context is not needed, and further the technical problem that in the prior art, the transmission of data at two ends of the connection needs the intermediary system, so that the data transmission efficiency is low is solved.

Optionally, the present application also provides an alternative embodiment of a method for data-command-event hybrid communication. Referring to fig. 4, a flow chart (a) of a method for data-command-event hybrid communication is described in detail as follows.

0) At the beginning of a Link, T2 or T3 calls the interfaces SendData, SendCommand or PostEvent, sends Data, sends or delivers a command or event with ID X, Data …, at which time T1 may have called the RecvData, recvccommand or WaitEvent interface.

1) If the current Link is in idle state, the step 2 is skipped, and if the current Link is in busy state, the step 6 is skipped, if the current Link is in busy state, the processing is completed soon because of short type; if "DataRecving, CmdRecving or EventWaiting" is in "busy cause", then step 7 is skipped, such busy being of "long type", i.e. presumably taking a longer time to receive new information.

2) The Link's transport channel is locked, the send data, command or delivery event is executed, and if the execution fails, typically for reasons such as disconnection, full send queue, etc., then a jump is made to step 4.

3) If successful and no ACK is needed (command correct answer), jump to step 4 immediately, otherwise wait to receive ACK for command at the Link, if the received contents do not match, place it in the receiving buffer, continue waiting for ACK, if match or time out, jump to step 4.

4) And unlocking the transmission channel of the Link, if the current Link waits to be sent, waking up to continue sending, otherwise, checking whether the current Link waits to be received, and if so, waking up to continue receiving, including processing to receive the cache.

5) And (4) ending: the send command interface on the Link returns a call, which may be successful, may fail, and the failure reason may be timeout or other reasons such as disconnection of the Link.

6) Firstly, judging whether Tn of AckRecving has an idle CPU core, if so, deserving 'busy' and the like, or whether Tn of CmdExecuring is running in other CPU cores, namely, whether Tn has other independent CPUs available for running when being busy and the like, and determining to deserve 'busy' and the like, adopting spin lock waiting to expect that the Link can be unlocked quickly, thereby reducing task switching, and if the Link is unlocked by a signal when being busy and the like, jumping to the step 1; if the busy time is exceeded, the system enters sleep and the like, namely the sleep is waited for the unlocking signal to be awakened or is awakened when the time is exceeded, and the system jumps to the step 1 or the step 5 respectively;

7) and the subprocess switches the Link to a receiving cache mode, unlocks the Link and jumps to the step 1.

Referring to fig. 5, a flow chart (ii) of a method of data-command-event hybrid communication is described in detail below,

0) beginning: at a certain time in a Link, Tn calls the interfaces RecvData, RecvCommand or WaitEvent, receiving or waiting for data, commands or events to reach this Link.

1) And if the current Link is in the idle state, jumping to the step 3.

2) Firstly, locking the transmission channel of the Link, starting to execute receiving or waiting operation, if the transmission protocol buffer area has the coming information, directly acquiring the information, and entering step 3; otherwise, waiting is carried out, the reason for awakening is judged until the awakening is awakened, if the information comes, the information is acquired, or the reason for awakening is overtime, and the awakening of the 2 reasons enters the step 3; if the wake-up reason is preemption (Preempt), then Link is switched to cache-waiting mode until awakened.

3) Unlocking the transmission channel of the Link, if a task waiting for sending exists, awakening the subprocess: link _ Send/Post.

4) The same as step 6 of Link _ Send/Post.

5) The Link already has cached information and directly acquires the cache commands or events.

6) The reception of this Link or the event process is ended.

Referring to fig. 6, a flow chart (ii) of a method of data-command-event hybrid communication is described in detail as follows.

0) Beginning: at a certain moment in a certain Link, Tn calls the interface AckCommand or CompleteEvent, acknowledging or completing the command or event that has been executed or processed to this Link.

1) If idle, go directly to step 2, if not, go directly to step 3.

2) Executing: the information of the Ack or Complete queued in the queue is transmitted first, and then the information of the Ack or Complete is transmitted.

3) Queuing: and putting the information waiting for Ack or Complete into a queue, and starting the queue after the queue is idle.

4) Receiving: the transmission of the Ack or Complete is completed.

In this embodiment, (1) when the "busy cause" of the transmission channel is a "short type", a spin busy wait or a task sleep wait is performed, or the link is switched to a reception suspension, so that the current task tries to acquire the transmission right of the channel again, where the spin busy first determines whether the current task and the task to be waited run in different CPUs at the same time, and the spin busy will be busy only if the current task and the task to be waited run concurrently, otherwise, the spin busy waits directly with sleep. (2) When the transmission channel busy factor is a long type, the transmission channel is switched to a suspended mode to wait for awakening. (3) The current task, upon receiving information beyond what the context expects, will dispatch it to and wake up to receive the pending task. (4) The task is in a receiving state, can be preempted and switched to a receiving suspension state, waits to be awakened again, directly takes information from the suspension cache queue, or enters the receiving waiting state again. (5) When the task confirms and completes information transmission, when the transmission channel is busy, the task is directly queued and then transmitted when the transmission channel is idle.

Through the embodiment provided by the application, the data-command-event hybrid communication method has the characteristics of supporting both traditional data receiving and sending, reliable synchronous command execution and reliable asynchronous event processing, and only needs to call the context of an interface without the context of a protocol stack.

It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.

According to another aspect of the embodiment of the present invention, there is also provided a data transmission apparatus for implementing the above data transmission method. As shown in fig. 7, the data transmission apparatus includes:

the receiving unit 71 is configured to receive, by the receiving end, a data transmission instruction sent by the sending end through the interface, where the receiving end and the sending end establish a communication connection Link, and the data transmission instruction is used to transmit data.

The determining unit 73 is configured to determine whether the receiving end receives data according to the current status of the connection Link.

According to the embodiment provided by the application, the receiving unit 71 is adopted to receive the data transmission instruction sent by the sending end through the interface, wherein the receiving end and the sending end establish communication connection Link, and the data transmission instruction is used for transmitting data; the determination unit 73 determines whether the receiving end receives data according to the current state of the connection Link. The method achieves the purposes that two ends of connection are established, an additional intermediary system is not needed, the two ends of connection can be independently scheduled, each end supports multithreading context to carry out concurrent data communication, the method has the reliable characteristic and the asynchronous characteristic, and no additional protocol stack context is needed, and further solves the technical problem that in the prior art, the transmission of data at two ends needs the intermediary system to cause low data transmission efficiency.

Optionally, the determining unit 73 may include: the receiving module is used for receiving the data sent by the sending end by the receiving end under the condition that the current state of the Link is an idle state; and the storage module is used for queuing the data sent by the sending end in a queue under the condition that the current state of the Link is a non-idle state.

Wherein, the receiving module may include: and the first receiving submodule is used for setting the current state of the connection Link to be a locking state, and the sending end sends the data in the transmission protocol buffer area.

Wherein, the receiving module may include: and the second receiving submodule is used for setting the current state of the connection Link to be a locking state, and the sending end wakes up and sends the waiting data.

It should be noted that, the second receiving submodule is further configured to wake up and send the waiting data when the waiting data is located in the transfer protocol buffer, or the waiting time of the waiting data is longer than the first predetermined time.

The second receiving submodule is further configured to switch the connection Link to the cache waiting mode until the connection Link is awakened when the waiting duration of the data is greater than the second duration.

The receiving unit 71 may include: and the processing module is used for allowing the connection Link to be preempted and switched to a receiving suspension state in the process that the receiving end receives the data sent by the sending end, waiting to be awakened again, directly fetching information from the suspension cache queue or entering a receiving waiting state again.

The above apparatus may further include: the receiving end is used for receiving the data sent by the sending end and sending a response message to the sending end under the condition that the current state of the Link is an idle state, wherein the response message is used for indicating that the data receiving is finished; and queuing the response information under the condition that the connection Link is in a non-idle state, and sending the response information when the connection Link is idle.

According to another aspect of the embodiment of the present invention, there is also provided a data transmission apparatus (ii) for implementing the data transmission method. As shown in fig. 8, the data transmission apparatus includes:

the sending unit 81 is configured to send a data transmission instruction to the sending end through the interface, where the receiving end and the sending end establish a communication connection Link, and the data transmission instruction is used to send data.

The determining unit 83 is configured to determine whether the sending end sends data according to the current state of the Link.

By the example provided by the application, the sending end of the sending unit 81 sends a data transmission instruction to the sending end through an interface, wherein the receiving end and the sending end establish a communication connection Link, and the data transmission instruction is used for sending data; the determination unit 83 determines whether to transmit data to the receiving end according to the current state of the connection Link. The method achieves the purposes that two ends of connection are established, an additional intermediary system is not needed, the two ends of connection can be independently scheduled, each end supports multithreading context to carry out concurrent data communication, the method has the reliable characteristic and the asynchronous characteristic, and no additional protocol stack context is needed, and further solves the technical problem that in the prior art, the transmission of data at two ends needs the intermediary system to cause low data transmission efficiency.

According to another aspect of the embodiment of the present invention, there is also provided an electronic device for implementing the data transmission method, where the electronic device may be the terminal device or the server shown in fig. 1. The present embodiment takes the electronic device as a server as an example for explanation. As shown in fig. 9, the electronic device comprises a memory 902 and a processor 904, the memory 902 having stored therein a computer program, the processor 904 being arranged to perform the steps of any of the above-described method embodiments by means of the computer program.

Optionally, in this embodiment, the electronic device may be located in at least one network device of a plurality of network devices of a computer network.

Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:

s1, the receiving end receives a data transmission instruction sent by the sending end through the interface, wherein the receiving end and the sending end establish a communication connection Link, and the data transmission instruction is used for transmitting data;

and S2, determining whether the receiving end receives data according to the current state of the Link.

Alternatively, it can be understood by those skilled in the art that the structure shown in fig. 9 is only an illustration, and the electronic device may also be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palmtop computer, a Mobile Internet Device (MID), a PAD, and the like. Fig. 9 is a diagram illustrating a structure of the electronic device. For example, the electronics may also include more or fewer components (e.g., network interfaces, etc.) than shown in FIG. 9, or have a different configuration than shown in FIG. 9.

The memory 902 may be used to store software programs and modules, such as program instructions/modules corresponding to the data transmission method and apparatus in the embodiments of the present invention, and the processor 904 executes various functional applications and data processing by running the software programs and modules stored in the memory 902, that is, implementing the data transmission method described above. The memory 902 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 902 may further include memory located remotely from the processor 904, which may be connected to the terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof. The memory 902 may be, but not limited to, specifically configured to store connection Link status information, transmission data, and other information. As an example, as shown in fig. 9, the memory 902 may include, but is not limited to, the receiving unit 71 and the determining unit 73 in the data transmission device. In addition, the data transmission device may further include, but is not limited to, other module units in the data transmission device, which is not described in detail in this example.

Optionally, the transmitting device 906 is used for receiving or sending data via a network. Examples of the network may include a wired network and a wireless network. In one example, the transmission device 906 includes a Network adapter (NIC) that can be connected to a router via a Network cable and other Network devices to communicate with the internet or a local area Network. In one example, the transmission device 906 is a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.

In other embodiments, the terminal device or the server may be a node in a distributed system, where the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting a plurality of nodes through a network communication. Nodes can form a Peer-To-Peer (P2P, Peer To Peer) network, and any type of computing device, such as a server, a terminal, and other electronic devices, can become a node in the blockchain system by joining the Peer-To-Peer network.

According to a further aspect of an embodiment of the present invention, there is also provided a computer-readable storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the steps of any of the above method embodiments when executed.

Alternatively, in the present embodiment, the above-mentioned computer-readable storage medium may be configured to store a computer program for executing the steps of:

s1, the receiving end receives a data transmission instruction sent by the sending end through the interface, wherein the receiving end and the sending end establish a communication connection Link, and the data transmission instruction is used for transmitting data;

and S2, determining whether the receiving end receives data according to the current state of the Link.

Alternatively, in this embodiment, a person skilled in the art may understand that all or part of the steps in the methods of the foregoing embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, Read-Only memories (ROMs), Random Access Memories (RAMs), magnetic or optical disks, and the like.

The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.

The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing one or more computer devices (which may be personal computers, servers, network devices, etc.) to execute all or part of the steps of the method according to the embodiments of the present invention.

In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.

In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.

The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

18页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种资源管理方法、装置及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!