CN114125023B - Method and device for determining data connection, storage medium and electronic device - Google Patents
Method and device for determining data connection, storage medium and electronic device Download PDFInfo
- Publication number
- CN114125023B CN114125023B CN202111340525.6A CN202111340525A CN114125023B CN 114125023 B CN114125023 B CN 114125023B CN 202111340525 A CN202111340525 A CN 202111340525A CN 114125023 B CN114125023 B CN 114125023B
- Authority
- CN
- China
- Prior art keywords
- cloud server
- data
- data connection
- connection
- data packet
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/148—Migration or transfer of sessions
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W36/00—Hand-off or reselection arrangements
- H04W36/14—Reselecting a network or an air interface
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W76/00—Connection management
- H04W76/10—Connection setup
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04W—WIRELESS COMMUNICATION NETWORKS
- H04W84/00—Network topologies
- H04W84/02—Hierarchically pre-organised networks, e.g. paging networks, cellular networks, WLAN [Wireless Local Area Network] or WLL [Wireless Local Loop]
- H04W84/10—Small scale networks; Flat hierarchical networks
- H04W84/12—WLAN [Wireless Local Area Networks]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/70—Reducing energy consumption in communication networks in wireless communication networks
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
Description
技术领域Technical field
本发明涉及通信领域,具体而言,涉及一种数据连接的确定方法及装置、存储介质及电子装置。The present invention relates to the field of communications, and specifically, to a method and device for determining a data connection, a storage medium and an electronic device.
背景技术Background technique
人们在使用手机等移动终端的时候,大多都是多个应用同时使用,即会经常在不同应用之间进行切换,如果应用存在与服务器的长连接,在现有技术中,应用并不知道从后台回到前台以后,之前与服务器建立的长连接是否可用,故应用需要重新连接服务器,与服务器建立新的连接。When people use mobile terminals such as mobile phones, most of them use multiple applications at the same time, that is, they often switch between different applications. If an application has a long connection with the server, in the existing technology, the application does not know where to start from. After the background returns to the foreground, whether the long connection previously established with the server is available, so the application needs to reconnect to the server and establish a new connection with the server.
进一步地,随着社会的发展,移动终端可用的网络越来越多,即移动终端可能会在不同的网络之间频繁切换。如果应用存在与服务器的长连接,在现有技术中,应用并不知道切换网络以后,之前与服务器建立的长连接是否可用,故应用也需要重新连接服务器,与服务器建立新的连接。Furthermore, with the development of society, more and more networks are available to mobile terminals, that is, mobile terminals may frequently switch between different networks. If the application has a long connection with the server, in the existing technology, the application does not know whether the long connection established with the server is available after switching networks, so the application also needs to reconnect to the server and establish a new connection with the server.
但如果应用从移动终端的前台到后台以后,立马就重新回到了前台,或者由于网络的抖动触发了切网,则应用与服务器建立的长连接很可能还是可用的,故应用如果每次在切网,或从后台回到前台以后都重新与服务器建立新的连接,则会导致服务器资源浪费,影响用户的体验感。However, if the application immediately returns to the foreground after going from the foreground to the background of the mobile terminal, or if network switching is triggered due to network jitter, the long connection established between the application and the server is likely to still be available. Therefore, if the application is switching every time Network, or re-establishing a new connection with the server after returning from the background to the foreground, will cause a waste of server resources and affect the user experience.
针对相关技术,应用在每次切换网络或从移动终端后台切换到前台以后,都需要和服务器建立新的长连接,导致服务器资源浪费的问题,目前尚未提出有效的解决方案。Regarding related technologies, every time an application switches networks or switches from the mobile terminal background to the foreground, it needs to establish a new long connection with the server, resulting in a waste of server resources. Currently, no effective solution has been proposed.
因此,有必要对相关技术予以改良以克服相关技术中的所述缺陷。Therefore, it is necessary to improve the related technology to overcome the defects in the related technology.
发明内容Contents of the invention
本发明实施例提供了一种数据连接的确定方法及装置、存储介质及电子装置,以至少解决应用在每次切换网络或从移动终端后台切换到前台以后,都需要和服务器建立新的长连接,导致服务器资源浪费的问题。Embodiments of the present invention provide a data connection determination method and device, a storage medium and an electronic device, so as to at least solve the problem that an application needs to establish a new long connection with the server every time it switches networks or switches from the mobile terminal background to the foreground. , leading to the problem of wasting server resources.
根据本发明实施例的一方面,提供一种数据连接的确定方法,包括:在目标应用上检测到目标操作的情况下,确定在第一时间与云端服务器进行数据传输的第一数据连接,其中,所述目标操作包括以下至少之一:切换网络操作,从移动终端的后台切换至所述移动终端的前台操作;通过所述第一数据连接向所述云端服务器发送第一数据包;在预设时间内通过所述第一数据连接接收到第二数据包的情况下,确定所述第一数据连接可用,并在第二时间通过所述第一数据连接与所述云端服务器进行数据传输,其中,所述第二数据包为所述云端服务器接收到所述第一数据包后发送的数据包,所述第一时间早于所述第二时间。According to an aspect of an embodiment of the present invention, a method for determining a data connection is provided, including: when a target operation is detected on a target application, determining a first data connection for data transmission with a cloud server at the first time, wherein , the target operation includes at least one of the following: switching network operations, switching from the background operation of the mobile terminal to the foreground operation of the mobile terminal; sending a first data packet to the cloud server through the first data connection; in advance If a second data packet is received through the first data connection within a certain time, it is determined that the first data connection is available, and data transmission is performed with the cloud server through the first data connection at the second time, Wherein, the second data packet is a data packet sent by the cloud server after receiving the first data packet, and the first time is earlier than the second time.
进一步地,通过所述第一数据连接向所述云端服务器发送第一数据包,包括:获取目标对象设置的第一数据包的目标数量;通过所述第一数据连接向所述云端服务器发送所述目标数量的第一数据包。Further, sending the first data packet to the cloud server through the first data connection includes: obtaining the target number of the first data packet set by the target object; sending the first data packet to the cloud server through the first data connection. The first data packet of the specified target number.
进一步地,通过所述第一数据连接向所述云端服务器发送第一数据包,包括:确定向所述云端服务器发送第一数据包的目标通信协议;在所述第一数据连接上使用所述目标通信协议向所述云端服务器发送第一数据包。Further, sending the first data packet to the cloud server through the first data connection includes: determining a target communication protocol for sending the first data packet to the cloud server; using the first data packet on the first data connection. The target communication protocol sends the first data packet to the cloud server.
进一步地,通过所述第一数据连接向所述云端服务器发送预设数量的第一数据包之后,所述方法还包括:在预设时间内通过所述第一数据连接未接收到第二数据包的情况下,断开与所述云端服务器建立的所述第一数据连接;向云端服务器发送连接请求,以建立与所述云端服务器进行数据传输的第二数据连接。Further, after sending a preset number of first data packets to the cloud server through the first data connection, the method further includes: not receiving second data through the first data connection within a preset time. In the case of a package, disconnect the first data connection established with the cloud server; send a connection request to the cloud server to establish a second data connection for data transmission with the cloud server.
进一步地,向云端服务器发送连接请求,以建立与所述云端服务器进行数据传输的第二数据连接,包括:通过超文本传输协议向云端服务器发送连接请求,其中,所述连接请求中具有验证信息;获取所述云端服务器发送的数据连接信息,其中,所述数据连接信息为所述云端服务器在对所述验证信息验证通过的情况下所发送的信息;所述数据连接信息包括:端口号;建立与所述云端服务器进行数据传输的第二数据连接,其中,所述第二数据连接用于在所述第二时间与所述云端服务器进行数据传输。Further, sending a connection request to the cloud server to establish a second data connection for data transmission with the cloud server includes: sending a connection request to the cloud server through hypertext transfer protocol, wherein the connection request contains verification information ; Obtain the data connection information sent by the cloud server, where the data connection information is the information sent by the cloud server when the verification information passes the verification; the data connection information includes: port number; Establish a second data connection for data transmission with the cloud server, wherein the second data connection is used for data transmission with the cloud server at the second time.
进一步地,获取所述云端服务器发送的数据连接信息,包括:获取所述云端服务器发送的加密后的数据连接信息;对所述加密后的数据连接信息进行解密,得到所述数据连接信息。Further, obtaining the data connection information sent by the cloud server includes: obtaining the encrypted data connection information sent by the cloud server; decrypting the encrypted data connection information to obtain the data connection information.
进一步地,确定在第一时间与云端服务器进行数据传输的第一数据连接之前,所述方法还包括:通过以下方式之一检测目标操作:监听所述移动终端的网络状态,在所述移动终端的网络状态从第一移动网络切换至第二移动网络,或所述移动终端从移动网络切换至无线保真WIFI网络,或所述移动终端从所述WIFI网络至所述移动网络的情况下,确定检测到目标操作,其中,所述移动网络包括:所述第一移动网络,所述第二移动网络;在监听到目标应用从移动终端的后台切换至所述移动终端的前台的情况下,确定检测到目标操作。Further, before determining the first data connection for data transmission with the cloud server at the first time, the method further includes: detecting the target operation in one of the following ways: monitoring the network status of the mobile terminal, and When the network status switches from the first mobile network to the second mobile network, or the mobile terminal switches from the mobile network to the wireless fidelity WIFI network, or the mobile terminal switches from the WIFI network to the mobile network, Determine that the target operation is detected, wherein the mobile network includes: the first mobile network and the second mobile network; in the case of monitoring that the target application is switched from the background of the mobile terminal to the foreground of the mobile terminal, Confirm that the target operation is detected.
根据本发明实施例的另一方面,还提供了一种数据连接的确定装置,包括:第一确定模块,用于在目标应用上检测到目标操作的情况下,确定在第一时间与云端服务器进行数据传输的第一数据连接,其中,所述目标操作包括以下至少之一:切换网络操作,从移动终端的后台切换至所述移动终端的前台操作;发送模块,用于通过所述第一数据连接向所述云端服务器发送第一数据包;第二确定模块,用于在预设时间内通过所述第一数据连接接收到第二数据包的情况下,确定所述第一数据连接可用,并在第二时间通过所述第一数据连接与所述云端服务器进行数据传输,其中,所述第二数据包为所述云端服务器接收到所述第一数据包后发送的数据包,所述第一时间早于所述第二时间。According to another aspect of the embodiment of the present invention, a device for determining a data connection is also provided, including: a first determination module, configured to determine, when a target operation is detected on the target application, to connect with the cloud server at the first time A first data connection for data transmission, wherein the target operation includes at least one of the following: switching network operation, switching from the background operation of the mobile terminal to the foreground operation of the mobile terminal; a sending module for passing the first The data connection sends a first data packet to the cloud server; a second determination module is configured to determine that the first data connection is available if a second data packet is received through the first data connection within a preset time , and perform data transmission with the cloud server through the first data connection at the second time, where the second data packet is a data packet sent by the cloud server after receiving the first data packet, so The first time is earlier than the second time.
根据本发明实施例的又一方面,还提供了一种计算机可读的存储介质,该计算机可读的存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述数据连接的确定方法。According to another aspect of the embodiment of the present invention, a computer-readable storage medium is also provided. The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the above-mentioned data connection when running. Determine the method.
根据本发明实施例的又一方面,还提供了一种电子装置,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,上述处理器通过计算机程序执行上述数据连接的确定方法。According to another aspect of the embodiment of the present invention, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above data through the computer program How to determine the connection.
通过本发明,在目标应用上检测到切换网络或从移动终端后台切换到前台以后,通过在第一时间与云端服务器建立的第一数据连接向云端服务器发送第一数据包;并在预设时间内通过第一数据连接接收到云端服务器响应的第二数据包的情况下,确定第一数据连接可用,并在第二时间通过第一数据连接与云端服务器进行数据传输。采用上述技术方案,解决了应用在每次切换网络或从移动终端后台切换到前台以后,都需要和服务器建立新的长连接,导致服务器资源浪费的问题。进而在确定与服务器建立的长连接可用的情况下,通过原长连接与服务器进行数据传输,不建立新的长连接,节约了服务器的资源。Through the present invention, after the target application detects switching networks or switching from the mobile terminal background to the foreground, the first data packet is sent to the cloud server through the first data connection established with the cloud server at the first time; and at the preset time When the second data packet responded by the cloud server is received through the first data connection, it is determined that the first data connection is available, and data transmission is performed with the cloud server through the first data connection at the second time. The above technical solution solves the problem of the application needing to establish a new long connection with the server every time it switches networks or switches from the mobile terminal background to the foreground, resulting in a waste of server resources. Then, when it is determined that the long connection established with the server is available, data is transmitted to the server through the original long connection without establishing a new long connection, which saves server resources.
附图说明Description of drawings
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示例性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The drawings described here are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the attached picture:
图1是本发明实施例的数据连接的确定方法的计算机终端的硬件结构框图;Figure 1 is a hardware structure block diagram of a computer terminal of a method for determining a data connection according to an embodiment of the present invention;
图2是根据本发明实施例的数据连接的确定方法的流程图;Figure 2 is a flow chart of a method for determining a data connection according to an embodiment of the present invention;
图3是根据本发明实施例的长短连接示意图;Figure 3 is a schematic diagram of long and short connections according to an embodiment of the present invention;
图4是根据本发明实施例的数据连接的确定方法的时序图;Figure 4 is a sequence diagram of a method for determining a data connection according to an embodiment of the present invention;
图5是根据本发明实施例的数据连接的确定装置的结构框图(一);Figure 5 is a structural block diagram (1) of a data connection determination device according to an embodiment of the present invention;
图6是根据本发明实施例的数据连接的确定装置的结构框图(二)。Figure 6 is a structural block diagram (2) of a device for determining a data connection according to an embodiment of the present invention.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only These are some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts should fall within the scope of protection of the present invention.
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances so that the embodiments of the invention described herein are capable of being practiced in sequences other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, e.g., a process, method, system, product, or apparatus that encompasses a series of steps or units and need not be limited to those explicitly listed. Those steps or elements may instead include other steps or elements not expressly listed or inherent to the process, method, product or apparatus.
本申请实施例中所提供的方法实施例可以在计算机终端或者类似的运算装置中执行。以运行在计算机终端上为例,图1是本发明实施例的数据连接的确定方法的计算机终端的硬件结构框图。如图1所示,计算机终端可以包括一个或多个(图1中仅示出一个)处理器102(处理器102可以包括但不限于微处理器(Microprocessor Unit,简称是MPU)或可编程逻辑器件(Programmable logic device,简称是PLD))和用于存储数据的存储器104,在一个示例性实施例中,上述计算机终端还可以包括用于通信功能的传输设备106以及输入输出设备108。本领域普通技术人员可以理解,图1所示的结构仅为示意,其并不对上述计算机终端的结构造成限定。例如,计算机终端还可包括比图1中所示更多或者更少的组件,或者具有与图1所示等同功能或比图1所示功能更多的不同的配置。The method embodiments provided in the embodiments of this application can be executed in a computer terminal or similar computing device. Taking running on a computer terminal as an example, FIG. 1 is a hardware structure block diagram of a computer terminal of a method for determining a data connection according to an embodiment of the present invention. As shown in Figure 1, the computer terminal may include one or more (only one is shown in Figure 1) processors 102 (the processor 102 may include but is not limited to a microprocessor unit (MPU for short) or programmable logic (Programmable logic device, PLD for short)) and a memory 104 for storing data. In an exemplary embodiment, the above-mentioned computer terminal may also include a transmission device 106 for communication functions and an input and output device 108. Persons of ordinary skill in the art can understand that the structure shown in Figure 1 is only illustrative, and it does not limit the structure of the above-mentioned computer terminal. For example, the computer terminal may also include more or fewer components than shown in FIG. 1 , or have a different configuration with equivalent functions or more functions than shown in FIG. 1 .
存储器104可用于存储计算机程序,例如,应用软件的软件程序以及模块,如本发明实施例中的数据连接的确定方法对应的计算机程序,处理器102通过运行存储在存储器104内的计算机程序,从而执行各种功能应用以及数据处理,即实现上述的方法。存储器104可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器104可进一步包括相对于处理器102远程设置的存储器,这些远程存储器可以通过网络连接至计算机终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for determining a data connection in the embodiment of the present invention. The processor 102 runs the computer program stored in the memory 104, thereby Execute various functional applications and data processing, that is, implement the above methods. Memory 104 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 104 may further include memory located remotely relative to the processor 102, and these remote memories may be connected to the computer terminal through a network. Examples of the above-mentioned networks include but are not limited to the Internet, intranets, local area networks, mobile communication networks and combinations thereof.
传输装置106用于经由一个网络接收或者发送数据。上述的网络具体实例可包括计算机终端的通信供应商提供的无线网络。在一个实例中,传输装置106包括一个网络适配器(Network Interface Controller,简称为NIC),其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输装置106可以为射频(Radio Frequency,简称为RF)模块,其用于通过无线方式与互联网进行通讯。The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC for short), which can be connected to other network devices through a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (Radio Frequency, RF for short) module, which is used to communicate with the Internet wirelessly.
为了解决本申请的技术问题,本实施例中提供了一种数据连接的确定方法,图2是根据本发明实施例的数据连接的确定方法的流程图,该流程包括如下步骤:In order to solve the technical problem of the present application, this embodiment provides a method for determining a data connection. Figure 2 is a flow chart of a method for determining a data connection according to an embodiment of the present invention. The process includes the following steps:
步骤S202,在目标应用上检测到目标操作的情况下,确定在第一时间与云端服务器进行数据传输的第一数据连接,其中,所述目标操作包括以下至少之一:切换网络操作,从移动终端的后台切换至所述移动终端的前台操作;Step S202: When a target operation is detected on the target application, determine the first data connection for data transmission with the cloud server at the first time, wherein the target operation includes at least one of the following: switching network operation, switching from mobile The background operation of the terminal is switched to the foreground operation of the mobile terminal;
需要说明的是,第一时间在目标应用检测到目标操作以前,具体的,第一时间为目标应用在没有切换网络以前的时间,或目标应用在上一次处于移动终端前台的时间。所述第一数据连接为在第一时间,目标应用与云端服务器建立的长连接。It should be noted that the first time is before the target application detects the target operation. Specifically, the first time is the time before the target application switches networks, or the time when the target application was last in the foreground of the mobile terminal. The first data connection is a long connection established between the target application and the cloud server at the first time.
为了更好的理解上述长连接,图3是根据本发明实施例的长短连接示意图,如图3中的(a)所示,目标应用在发送数据以后,不关闭此连接,可以继续使用此连接发送数据。而如图3中的(b)所示,目标应用每发一次数据后,就关闭连接,进而在下一次发送数据的时候,重新建立新的连接。In order to better understand the above long connection, Figure 3 is a schematic diagram of a long and short connection according to an embodiment of the present invention. As shown in (a) in Figure 3, the target application does not close the connection after sending data and can continue to use the connection. send data. As shown in (b) of Figure 3, the target application closes the connection every time it sends data, and then re-establishes a new connection the next time it sends data.
步骤S204,通过所述第一数据连接向所述云端服务器发送第一数据包;Step S204: Send the first data packet to the cloud server through the first data connection;
需要说明的是,目标应用向云端服务器发送第一数据包是为了进行心跳检测,从而确定第一数据连接是否可用。It should be noted that the target application sends the first data packet to the cloud server for heartbeat detection to determine whether the first data connection is available.
步骤S206,在预设时间内通过所述第一数据连接接收到第二数据包的情况下,确定所述第一数据连接可用,并在第二时间通过所述第一数据连接与所述云端服务器进行数据传输,其中,所述第二数据包为所述云端服务器接收到所述第一数据包后发送的数据包,所述第一时间早于所述第二时间。Step S206: If the second data packet is received through the first data connection within a preset time, determine that the first data connection is available, and communicate with the cloud through the first data connection at the second time. The server performs data transmission, wherein the second data packet is a data packet sent by the cloud server after receiving the first data packet, and the first time is earlier than the second time.
需要说明的是,预设时间是经过多次实验后所确定的。在一个示例性的实施例中,预设时间为2s。It should be noted that the preset time is determined after many experiments. In an exemplary embodiment, the preset time is 2 seconds.
在一个实施例性的实施例中,上述步骤可以应用在目标应用上。In an exemplary embodiment, the above steps may be applied to the target application.
通过上述步骤,在目标应用上检测到切换网络或从移动终端后台切换到前台以后,通过在第一时间与云端服务器建立的第一数据连接向云端服务器发送第一数据包;并在预设时间内通过第一数据连接接收到云端服务器响应的第二数据包的情况下,确定第一数据连接可用,并在第二时间通过第一数据连接与云端服务器进行数据传输。采用上述技术方案,解决了应用在每次切换网络或从移动终端后台切换到前台以后,都需要和服务器建立新的长连接,导致服务器资源浪费的问题。进而在确定与服务器建立的长连接可用的情况下,通过原长连接与服务器进行数据传输,不建立新的长连接,节约了服务器的资源。Through the above steps, after the target application detects switching networks or switching from the mobile terminal background to the foreground, the first data packet is sent to the cloud server through the first data connection established with the cloud server at the first time; and at the preset time When the second data packet responded by the cloud server is received through the first data connection, it is determined that the first data connection is available, and data transmission is performed with the cloud server through the first data connection at the second time. The above technical solution solves the problem of the application needing to establish a new long connection with the server every time it switches networks or switches from the mobile terminal background to the foreground, resulting in a waste of server resources. Then, when it is determined that the long connection established with the server is available, data is transmitted to the server through the original long connection without establishing a new long connection, which saves server resources.
在一个可选的实施例中,通过第一数据连接向云端服务器发送第一数据包,可以通过以下方式实现:获取目标对象设置的第一数据包的目标数量;通过所述第一数据连接向所述云端服务器发送所述目标数量的第一数据包。In an optional embodiment, sending the first data packet to the cloud server through the first data connection can be achieved in the following manner: obtaining the target number of first data packets set by the target object; sending the first data packet to the cloud server through the first data connection. The cloud server sends the target number of first data packets.
需要说明的是,如果目标应用通过第一数据连接给云端服务器发送一个第一数据包,并在2s内收到了云端服务器发送的第二数据包,则证明第一数据连接可用。但可能会存在第一数据连接可用,但在2s内没有收到云端服务器发送的第二数据包的情况。导致此种现象的原因主要有两种,(1)由于网络不稳定,目标应用发送给云端服务器的第一数据包在发送的过程中丢失;(2)由于网络延迟,目标应用在2s以后才收到云端服务器发送的第二数据包。为了解决在发送第一数据包的过程中,第一数据包的丢失,故需要通过第一数据连接依次发送多个第一数据包给云端服务器,只要在发送数据包后的2s内收到一个云端服务器发送的第二数据包,则认为第一数据连接可用。需要说明的是,只要预设时间没有收到云端服务器发送的第二数据包,不管第一数据连接是否可用,都断开第一数据连接,重新与云端服务器建立新的第二数据连接。It should be noted that if the target application sends a first data packet to the cloud server through the first data connection and receives the second data packet sent by the cloud server within 2 seconds, it proves that the first data connection is available. However, there may be situations where the first data connection is available, but the second data packet sent by the cloud server is not received within 2 seconds. There are two main reasons for this phenomenon. (1) Due to network instability, the first data packet sent by the target application to the cloud server is lost during the transmission process; (2) Due to network delay, the target application waits 2 seconds for the data packet to be sent to the cloud server. Receive the second data packet sent by the cloud server. In order to solve the problem of the loss of the first data packet during the process of sending the first data packet, multiple first data packets need to be sent to the cloud server in sequence through the first data connection. As long as one is received within 2s after sending the data packet The second data packet sent by the cloud server is considered to be available for the first data connection. It should be noted that as long as the second data packet sent by the cloud server is not received within the preset time, regardless of whether the first data connection is available, the first data connection will be disconnected and a new second data connection will be re-established with the cloud server.
可选的,通过第一数据连接向所述云端服务器发送第一数据包的时候,还需要确定向所述云端服务器发送第一数据包的目标通信协议,进而在第一数据连接上使用所述目标通信协议向所述云端服务器发送第一数据包。Optionally, when sending the first data packet to the cloud server through the first data connection, it is also necessary to determine the target communication protocol for sending the first data packet to the cloud server, and then use the first data packet on the first data connection. The target communication protocol sends the first data packet to the cloud server.
需要说明的是,目标应用和云端服务器之间的通信协议有多种,包括但不限于TCP,UDP。进而目标应用需要从通信协议中确定目标通信协议。在一个示例性的实施例中,目标通信协议为TCP,进而目标应用在第一数据连接上使用TCP向云端服务器发送第一数据包。It should be noted that there are many communication protocols between the target application and the cloud server, including but not limited to TCP and UDP. Then the target application needs to determine the target communication protocol from the communication protocol. In an exemplary embodiment, the target communication protocol is TCP, and the target application uses TCP to send the first data packet to the cloud server on the first data connection.
进一步的,如果在预设时间内通过所述第一数据连接未接收到第二数据包的情况下,断开与所述云端服务器建立的所述第一数据连接;向云端服务器发送连接请求,以建立与所述云端服务器进行数据传输的第二数据连接。Further, if the second data packet is not received through the first data connection within a preset time, disconnect the first data connection established with the cloud server; send a connection request to the cloud server, To establish a second data connection for data transmission with the cloud server.
也就是说,如果目标应用在预设时间内没有收到云端服务器发送的第二数据包,则认为第一数据连接不可用,进而需要向云端服务器发送连接请求,请求建立与云端服务器进行数据传输的第二数据连接。That is to say, if the target application does not receive the second data packet sent by the cloud server within the preset time, it is considered that the first data connection is unavailable, and then needs to send a connection request to the cloud server to request the establishment of data transmission with the cloud server. of the second data connection.
在一个可选的实施例中,向云端服务器发送连接请求,以建立与云端服务器进行数据传输的第二数据连接,可以通过以下方式实现:通过超文本传输协议向云端服务器发送连接请求,其中,所述连接请求中具有验证信息;获取所述云端服务器发送的数据连接信息,其中,所述数据连接信息为所述云端服务器在对所述验证信息验证通过的情况下所发送的信息;所述数据连接信息包括:端口号;建立与所述云端服务器进行数据传输的第二数据连接,其中,所述第二数据连接用于在所述第二时间与所述云端服务器进行数据传输。In an optional embodiment, sending a connection request to the cloud server to establish a second data connection for data transmission with the cloud server can be implemented in the following manner: sending a connection request to the cloud server through Hypertext Transfer Protocol, where, The connection request contains verification information; and obtains the data connection information sent by the cloud server, wherein the data connection information is the information sent by the cloud server when the verification information passes the verification; The data connection information includes: a port number; establishing a second data connection for data transmission with the cloud server, wherein the second data connection is used for data transmission with the cloud server at the second time.
也就是说,目标应用可以通过超文本传输协议向云端服务器发送连接请求,云端服务器会对连接请求进行验证,在验证通过的情况下,才向目标应用发送数据连接信息,目标应用在接收到数据连接信息以后,就可以根据数据连接信息与服务器建立第二数据连接。需要说明是,数据连接信息包括但不限于端口号。That is to say, the target application can send a connection request to the cloud server through the Hypertext Transfer Protocol. The cloud server will verify the connection request. Only when the verification passes, will the target application send data connection information. The target application will receive the data after receiving the data. After the connection information is obtained, a second data connection can be established with the server based on the data connection information. It should be noted that the data connection information includes but is not limited to port number.
在一个可选的实施例中,目标应用获取的是云端服务器采用发送的加密后的数据连接信息,进而目标应用需要对所述加密后的数据连接信息进行解密,得到数据连接信息。需要说明的是,加密算法可以是非对称加密算法。In an optional embodiment, the target application obtains the encrypted data connection information sent by the cloud server, and then the target application needs to decrypt the encrypted data connection information to obtain the data connection information. It should be noted that the encryption algorithm may be an asymmetric encryption algorithm.
进一步地,目标应用可以通过以下方式之一检测目标操作:监听所述移动终端的网络状态,在所述移动终端的网络状态从第一移动网络切换至第二移动网络,或所述移动终端从移动网络切换至无线保真WIFI网络,或所述移动终端从所述WIFI网络至所述移动网络的情况下,确定检测到目标操作,其中,所述移动网络包括:所述第一移动网络,所述第二移动网络;在监听到目标应用从移动终端的后台切换至所述移动终端的前台的情况下,确定检测到目标操作。Further, the target application can detect the target operation in one of the following ways: monitoring the network status of the mobile terminal, switching from the first mobile network to the second mobile network when the network status of the mobile terminal is switched, or the mobile terminal switching from When the mobile network switches to a wireless fidelity WIFI network, or when the mobile terminal switches from the WIFI network to the mobile network, it is determined that the target operation is detected, wherein the mobile network includes: the first mobile network, The second mobile network: determines that the target operation is detected when it detects that the target application is switched from the background of the mobile terminal to the foreground of the mobile terminal.
显然,上述所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。为了更好的理解上述数据连接的确定方法,以下结合实施例对上述过程进行说明,但不用于限定本发明实施例的技术方案,具体地:Obviously, the above-described embodiments are only part of the embodiments of the present invention, rather than all embodiments. In order to better understand the method for determining the above-mentioned data connection, the above-mentioned process will be described below with reference to embodiments, but this is not intended to limit the technical solutions of the embodiments of the present invention. Specifically:
在一个可选的实施例中,图4是根据本发明实施例的数据连接的确定方法的时序图,具体的,在APP从移动终端的后台切换前台,或切换网络以后,在原有的长连接(相当于上述实施例中的第一数据连接)的基础上,主动向服务器发起心跳探测(相当于上述实施例中的发送第一数据包),根据心跳探测结果判断当前连接的可用性,具体的,如果APP在预设时间内没有接收到云端服务器的响应,则认为原连接不可用。需要说明的是,APP可以发起多次心跳探测(相当于上述实施例中的发送预设数目的第一数据包),心跳探测可以是TCP或UDP等协议,不限于图4中的TCP方式。In an optional embodiment, Figure 4 is a sequence diagram of a method for determining a data connection according to an embodiment of the present invention. Specifically, after the APP switches from the background of the mobile terminal to the foreground or switches the network, the original long connection (equivalent to the first data connection in the above embodiment), actively initiate a heartbeat detection to the server (equivalent to sending the first data packet in the above embodiment), and determine the availability of the current connection based on the heartbeat detection result. Specifically , if the APP does not receive a response from the cloud server within the preset time, the original connection is considered unavailable. It should be noted that the APP can initiate multiple heartbeat detections (equivalent to sending a preset number of first data packets in the above embodiment). The heartbeat detection can be a protocol such as TCP or UDP, and is not limited to the TCP method in Figure 4.
此外,本发明实施例的上述技术方案,可以减少目标应用和云端服务器之间的长连接次数,进而节省服务器资源,减少重连带来的失败。In addition, the above technical solutions of the embodiments of the present invention can reduce the number of long connections between the target application and the cloud server, thereby saving server resources and reducing failures caused by reconnections.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本发明各个实施例的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus the necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is Better implementation. Based on this understanding, the technical solution of the present invention can be embodied in the form of a software product in essence or the part that contributes to the existing technology. The computer software product is stored in a storage medium (such as ROM/RAM, disk, CD), including several instructions to cause a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of various embodiments of the present invention.
在本实施例中还提供了一种数据连接的确定装置,该装置用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的设备较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。This embodiment also provides a device for determining a data connection, which is used to implement the above embodiments and preferred implementations. What has already been described will not be described again. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
图5是根据本发明实施例的数据连接的确定装置的结构框图(一),该装置包括:Figure 5 is a structural block diagram (1) of a device for determining a data connection according to an embodiment of the present invention. The device includes:
第一确定模块52,用于在目标应用上检测到目标操作的情况下,确定在第一时间与云端服务器进行数据传输的第一数据连接,其中,所述目标操作包括以下至少之一:切换网络操作,从移动终端的后台切换至所述移动终端的前台操作;The first determination module 52 is configured to determine the first data connection for data transmission with the cloud server at the first time when a target operation is detected on the target application, wherein the target operation includes at least one of the following: switching Network operation, switching from the background operation of the mobile terminal to the foreground operation of the mobile terminal;
发送模块54,用于通过所述第一数据连接向所述云端服务器发送第一数据包;A sending module 54, configured to send a first data packet to the cloud server through the first data connection;
第二确定模块56,用于在预设时间内通过所述第一数据连接接收到第二数据包的情况下,确定所述第一数据连接可用,并在第二时间通过所述第一数据连接与所述云端服务器进行数据传输,其中,所述第二数据包为所述云端服务器接收到所述第一数据包后发送的数据包,所述第一时间早于所述第二时间。The second determination module 56 is configured to determine that the first data connection is available when the second data packet is received through the first data connection within a preset time, and pass the first data packet at the second time. Connect to the cloud server for data transmission, wherein the second data packet is a data packet sent by the cloud server after receiving the first data packet, and the first time is earlier than the second time.
通过上述步骤,在目标应用上检测到切换网络或从移动终端后台切换到前台以后,通过在第一时间与云端服务器建立的第一数据连接向云端服务器发送第一数据包;并在预设时间内通过第一数据连接接收到云端服务器响应的第二数据包的情况下,确定第一数据连接可用,并在第二时间通过第一数据连接与云端服务器进行数据传输。采用上述技术方案,解决了应用在每次切换网络或从移动终端后台切换到前台以后,都需要和服务器建立新的长连接,导致服务器资源浪费的问题。进而在确定与服务器建立的长连接可用的情况下,通过原长连接与服务器进行数据传输,不建立新的长连接,节约了服务器的资源。Through the above steps, after the target application detects switching networks or switching from the mobile terminal background to the foreground, the first data packet is sent to the cloud server through the first data connection established with the cloud server at the first time; and at the preset time When the second data packet responded by the cloud server is received through the first data connection, it is determined that the first data connection is available, and data transmission is performed with the cloud server through the first data connection at the second time. The above technical solution solves the problem of the application needing to establish a new long connection with the server every time it switches networks or switches from the mobile terminal background to the foreground, resulting in a waste of server resources. Then, when it is determined that the long connection established with the server is available, data is transmitted to the server through the original long connection without establishing a new long connection, which saves server resources.
可选的,发送模块54还用于获取目标对象设置的第一数据包的目标数量;通过所述第一数据连接向所述云端服务器发送所述目标数量的第一数据包。Optionally, the sending module 54 is also configured to obtain a target number of first data packets set by the target object; and send the target number of first data packets to the cloud server through the first data connection.
需要说明的是,如果目标应用通过第一数据连接给云端服务器发送一个第一数据包,并在2s内收到了云端服务器发送的第二数据包,则证明第一数据连接可用。但可能会存在第一数据连接可用,但在2s内没有收到云端服务器发送的第二数据包的情况。导致此种现象的原因主要有两种,(1)由于网络不稳定,目标应用发送给云端服务器的第一数据包在发送的过程中丢失;(2)由于网络延迟,目标应用在2s以后才收到云端服务器发送的第二数据包。为了解决在发送第一数据包的过程中,第一数据包的丢失,故需要通过第一数据连接依次发送多个第一数据包给云端服务器,只要在发送数据包后的2s内收到一个云端服务器发送的第二数据包,则认为第一数据连接可用。需要说明的是,只要预设时间没有收到云端服务器发送的第二数据包,不管第一数据连接是否可用,都断开第一数据连接,重新与云端服务器建立新的第二数据连接。It should be noted that if the target application sends a first data packet to the cloud server through the first data connection and receives the second data packet sent by the cloud server within 2 seconds, it proves that the first data connection is available. However, there may be situations where the first data connection is available, but the second data packet sent by the cloud server is not received within 2 seconds. There are two main reasons for this phenomenon. (1) Due to network instability, the first data packet sent by the target application to the cloud server is lost during the transmission process; (2) Due to network delay, the target application waits 2 seconds for the data packet to be sent to the cloud server. Receive the second data packet sent by the cloud server. In order to solve the problem of the loss of the first data packet during the process of sending the first data packet, multiple first data packets need to be sent to the cloud server in sequence through the first data connection. As long as one is received within 2s after sending the data packet The second data packet sent by the cloud server is considered to be available for the first data connection. It should be noted that as long as the second data packet sent by the cloud server is not received within the preset time, regardless of whether the first data connection is available, the first data connection will be disconnected and a new second data connection will be re-established with the cloud server.
可选的,发送模块54还用于确定向所述云端服务器发送第一数据包的目标通信协议;在所述第一数据连接上使用所述目标通信协议向所述云端服务器发送第一数据包。Optionally, the sending module 54 is also used to determine the target communication protocol for sending the first data packet to the cloud server; and use the target communication protocol to send the first data packet to the cloud server on the first data connection. .
图6是根据本发明实施例的数据连接的确定装置的结构框图(二),该装置包括:建立模块58。Figure 6 is a structural block diagram (2) of a device for determining a data connection according to an embodiment of the present invention. The device includes: an establishment module 58.
可选的,建立模块58还用于在预设时间内通过所述第一数据连接未接收到第二数据包的情况下,断开与所述云端服务器建立的所述第一数据连接;向云端服务器发送连接请求,以建立与所述云端服务器进行数据传输的第二数据连接。Optionally, the establishment module 58 is also configured to disconnect the first data connection established with the cloud server if the second data packet is not received through the first data connection within a preset time; The cloud server sends a connection request to establish a second data connection for data transmission with the cloud server.
可选的,建立模块58还用于通过超文本传输协议向云端服务器发送连接请求,其中,所述连接请求中具有验证信息;获取所述云端服务器发送的数据连接信息,其中,所述数据连接信息为所述云端服务器在对所述验证信息验证通过的情况下所发送的信息;所述数据连接信息包括:端口号;建立与所述云端服务器进行数据传输的第二数据连接,其中,所述第二数据连接用于在所述第二时间与所述云端服务器进行数据传输。Optionally, the establishment module 58 is also used to send a connection request to the cloud server through hypertext transfer protocol, wherein the connection request contains verification information; and obtain the data connection information sent by the cloud server, wherein the data connection The information is the information sent by the cloud server when the verification information passes the verification; the data connection information includes: a port number; establishing a second data connection for data transmission with the cloud server, wherein: The second data connection is used for data transmission with the cloud server at the second time.
可选的,建立模块58还用于获取所述云端服务器发送的加密后的数据连接信息;对所述加密后的数据连接信息进行解密,得到所述数据连接信息。Optionally, the establishment module 58 is also used to obtain the encrypted data connection information sent by the cloud server; decrypt the encrypted data connection information to obtain the data connection information.
可选的,第一确定模块52还用于通过以下方式之一检测目标操作:监听所述移动终端的网络状态,在所述移动终端的网络状态从第一移动网络切换至第二移动网络,或所述移动终端从移动网络切换至无线保真WIFI网络,或所述移动终端从所述WIFI网络至所述移动网络的情况下,确定检测到目标操作,其中,所述移动网络包括:所述第一移动网络,所述第二移动网络;在监听到目标应用从移动终端的后台切换至所述移动终端的前台的情况下,确定检测到目标操作。Optionally, the first determination module 52 is also configured to detect the target operation in one of the following ways: monitor the network status of the mobile terminal, and switch from the first mobile network to the second mobile network when the network status of the mobile terminal is, Or when the mobile terminal switches from the mobile network to the wireless fidelity WIFI network, or when the mobile terminal switches from the WIFI network to the mobile network, it is determined that the target operation is detected, wherein the mobile network includes: The first mobile network and the second mobile network determine that the target operation is detected when it is monitored that the target application is switched from the background of the mobile terminal to the foreground of the mobile terminal.
本发明的实施例还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。Embodiments of the present invention also provide a computer-readable storage medium that stores a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when running.
可选地,在本实施例中,上述存储介质可以被设置为存储用于执行以下步骤的计算机程序:Optionally, in this embodiment, the above-mentioned storage medium may be configured to store a computer program for performing the following steps:
S1,在目标应用上检测到目标操作的情况下,确定在第一时间与云端服务器进行数据传输的第一数据连接,其中,所述目标操作包括以下至少之一:切换网络操作,从移动终端的后台切换至所述移动终端的前台操作;S1. When a target operation is detected on the target application, determine the first data connection for data transmission with the cloud server at the first time, wherein the target operation includes at least one of the following: switching network operation, starting from the mobile terminal Switch the background operation to the foreground operation of the mobile terminal;
S2,通过所述第一数据连接向所述云端服务器发送第一数据包;S2: Send the first data packet to the cloud server through the first data connection;
S3,在预设时间内通过所述第一数据连接接收到第二数据包的情况下,确定所述第一数据连接可用,并在第二时间通过所述第一数据连接与所述云端服务器进行数据传输,其中,所述第二数据包为所述云端服务器接收到所述第一数据包后发送的数据包,所述第一时间早于所述第二时间。S3: If the second data packet is received through the first data connection within the preset time, determine that the first data connection is available, and communicate with the cloud server through the first data connection at the second time. Data transmission is performed, wherein the second data packet is a data packet sent by the cloud server after receiving the first data packet, and the first time is earlier than the second time.
在一个示例性实施例中,上述计算机可读存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储计算机程序的介质。In an exemplary embodiment, the computer-readable storage medium may include but is not limited to: USB flash drive, read-only memory (ROM), random access memory (Random Access Memory, RAM) , mobile hard disk, magnetic disk or optical disk and other media that can store computer programs.
本实施例中的具体示例可以参考上述实施例及示例性实施方式中所描述的示例,本实施例在此不再赘述。For specific examples in this embodiment, reference may be made to the examples described in the above-mentioned embodiments and exemplary implementations, and details will not be described again in this embodiment.
本发明的实施例还提供了一种电子装置,包括存储器和处理器,该存储器中存储有计算机程序,该处理器被设置为运行计算机程序以执行上述任一项方法实施例中的步骤。An embodiment of the present invention also provides an electronic device, including a memory and a processor. A computer program is stored in the memory, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
可选地,在本实施例中,上述处理器可以被设置为通过计算机程序执行以下步骤:Optionally, in this embodiment, the above-mentioned processor may be configured to perform the following steps through a computer program:
S1,在目标应用上检测到目标操作的情况下,确定在第一时间与云端服务器进行数据传输的第一数据连接,其中,所述目标操作包括以下至少之一:切换网络操作,从移动终端的后台切换至所述移动终端的前台操作;S1. When a target operation is detected on the target application, determine the first data connection for data transmission with the cloud server at the first time, wherein the target operation includes at least one of the following: switching network operation, starting from the mobile terminal Switch the background operation to the foreground operation of the mobile terminal;
S2,通过所述第一数据连接向所述云端服务器发送第一数据包;S2: Send the first data packet to the cloud server through the first data connection;
S3,在预设时间内通过所述第一数据连接接收到第二数据包的情况下,确定所述第一数据连接可用,并在第二时间通过所述第一数据连接与所述云端服务器进行数据传输,其中,所述第二数据包为所述云端服务器接收到所述第一数据包后发送的数据包,所述第一时间早于所述第二时间。S3: If the second data packet is received through the first data connection within the preset time, determine that the first data connection is available, and communicate with the cloud server through the first data connection at the second time. Data transmission is performed, wherein the second data packet is a data packet sent by the cloud server after receiving the first data packet, and the first time is earlier than the second time.
在一个示例性实施例中,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。In an exemplary embodiment, the above-mentioned electronic device may further include a transmission device and an input-output device, wherein the transmission device is connected to the above-mentioned processor, and the input-output device is connected to the above-mentioned processor.
本实施例中的具体示例可以参考上述实施例及示例性实施方式中所描述的示例,本实施例在此不再赘述。For specific examples in this embodiment, reference may be made to the examples described in the above-mentioned embodiments and exemplary implementations, and details will not be described again in this embodiment.
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present invention can be implemented using general-purpose computing devices. They can be concentrated on a single computing device, or distributed across a network composed of multiple computing devices. They may be implemented in program code executable by a computing device, such that they may be stored in a storage device for execution by the computing device, and in some cases may be executed in a sequence different from that shown herein. Or the described steps can be implemented by making them into individual integrated circuit modules respectively, or by making multiple modules or steps among them into a single integrated circuit module. As such, the invention is not limited to any specific combination of hardware and software.
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modifications, equivalent substitutions, improvements, etc. made within the principles of the present invention shall be included in the protection scope of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111340525.6A CN114125023B (en) | 2021-11-12 | 2021-11-12 | Method and device for determining data connection, storage medium and electronic device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111340525.6A CN114125023B (en) | 2021-11-12 | 2021-11-12 | Method and device for determining data connection, storage medium and electronic device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114125023A CN114125023A (en) | 2022-03-01 |
CN114125023B true CN114125023B (en) | 2024-03-22 |
Family
ID=80379273
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111340525.6A Active CN114125023B (en) | 2021-11-12 | 2021-11-12 | Method and device for determining data connection, storage medium and electronic device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114125023B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115022074B (en) * | 2022-06-24 | 2024-10-11 | 中国电信股份有限公司 | User authentication authorization method, device, medium and equipment |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2015188761A1 (en) * | 2014-06-12 | 2015-12-17 | Tencent Technology (Shenzhen) Company Limited | Traffic acquiring method and apparatus based on operating system |
CN105893129A (en) * | 2016-03-30 | 2016-08-24 | 北京小米移动软件有限公司 | Processing method and device for application programs in terminal |
CN106941713A (en) * | 2017-05-16 | 2017-07-11 | 努比亚技术有限公司 | It is a kind of to reduce the method and its device of mobile terminal power consumption |
CN107635261A (en) * | 2017-09-18 | 2018-01-26 | 维沃移动通信有限公司 | The method for handover control and mobile terminal of a kind of network |
CN107645529A (en) * | 2016-07-21 | 2018-01-30 | 腾讯科技(深圳)有限公司 | Heartbeat packet transmission method and device |
CN108040091A (en) * | 2017-11-27 | 2018-05-15 | 腾讯数码(天津)有限公司 | Data processing method, device and storage medium |
CN110312286A (en) * | 2018-03-27 | 2019-10-08 | 华为技术有限公司 | Network switching method, communication device and communication equipment |
-
2021
- 2021-11-12 CN CN202111340525.6A patent/CN114125023B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2015188761A1 (en) * | 2014-06-12 | 2015-12-17 | Tencent Technology (Shenzhen) Company Limited | Traffic acquiring method and apparatus based on operating system |
CN105893129A (en) * | 2016-03-30 | 2016-08-24 | 北京小米移动软件有限公司 | Processing method and device for application programs in terminal |
CN107645529A (en) * | 2016-07-21 | 2018-01-30 | 腾讯科技(深圳)有限公司 | Heartbeat packet transmission method and device |
CN106941713A (en) * | 2017-05-16 | 2017-07-11 | 努比亚技术有限公司 | It is a kind of to reduce the method and its device of mobile terminal power consumption |
CN107635261A (en) * | 2017-09-18 | 2018-01-26 | 维沃移动通信有限公司 | The method for handover control and mobile terminal of a kind of network |
CN108040091A (en) * | 2017-11-27 | 2018-05-15 | 腾讯数码(天津)有限公司 | Data processing method, device and storage medium |
CN110312286A (en) * | 2018-03-27 | 2019-10-08 | 华为技术有限公司 | Network switching method, communication device and communication equipment |
Also Published As
Publication number | Publication date |
---|---|
CN114125023A (en) | 2022-03-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3694160B1 (en) | Date transmission method, apparatus and device | |
CN105635248A (en) | Method and system for releasing TCP (Transmission Control Protocol) connection resources | |
US11233694B2 (en) | Method and device for processing communication path | |
CN112165447B (en) | WAF equipment-based network security monitoring method, system and electronic device | |
CN107465613B (en) | Link aggregation interface communication state switching method and device | |
US10594844B2 (en) | Method and system for wireless network bilateral accelerated transmission | |
KR20050021522A (en) | Method for calculating a transmission window size | |
CN111935108B (en) | Cloud data security access control method and device, electronic device and storage medium | |
WO2019041371A1 (en) | Internet of things number-of-connections-based router switching method and device | |
CN114125023B (en) | Method and device for determining data connection, storage medium and electronic device | |
CN108141901B (en) | Method and terminal for controlling service connection | |
WO2018053894A1 (en) | Internet-of-things access point handover method and device based on transmission rate | |
CN107241758A (en) | Network control method, network control device and intelligent terminal | |
US9819730B2 (en) | System and method for network access based on application layer data | |
CN107277881A (en) | Network switching method, network switching device and intelligent terminal | |
CN106487696A (en) | Link failure detection method and device | |
US20160309362A1 (en) | Access Node, Mobility Management Network Element, and Paging Message Processing Method | |
CN107431965B (en) | A method and device for realizing transmission control protocol TCP transmission | |
EP3065445B1 (en) | Method, cse, and system for transmitting m2m application request | |
EP3223493A1 (en) | Point-to-point protocol (ppp)-based dial-on-demand method and device, and computer storage medium | |
US9967190B2 (en) | Session link control method and apparatus, and computer storage medium | |
WO2014201771A1 (en) | Method for releasing wireless link resource and user equipment | |
WO2017219667A1 (en) | Method, device, and system for modifying mss | |
WO2017206460A1 (en) | Method, apparatus and device for setting maximum transmission unit value | |
CN107086958A (en) | A data transmission method, WAP gateway and system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |