CN111328155B - Data transmission method, device, storage medium and electronic equipment - Google Patents

Data transmission method, device, storage medium and electronic equipment Download PDF

Info

Publication number
CN111328155B
CN111328155B CN202010125417.6A CN202010125417A CN111328155B CN 111328155 B CN111328155 B CN 111328155B CN 202010125417 A CN202010125417 A CN 202010125417A CN 111328155 B CN111328155 B CN 111328155B
Authority
CN
China
Prior art keywords
port
mobile terminal
socket connection
data transmission
electronic equipment
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
Application number
CN202010125417.6A
Other languages
Chinese (zh)
Other versions
CN111328155A (en
Inventor
张海龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN202010125417.6A priority Critical patent/CN111328155B/en
Publication of CN111328155A publication Critical patent/CN111328155A/en
Application granted granted Critical
Publication of CN111328155B publication Critical patent/CN111328155B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/18Management of setup rejection or failure
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/19Connection re-establishment
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/20Manipulation of established connections

Abstract

The embodiment of the application discloses a data transmission method, a data transmission device, a storage medium and electronic equipment, wherein the data transmission is carried out between the electronic equipment and a mobile terminal through socket connection, and the socket connection is established between the electronic equipment and the mobile terminal; when the socket connection disconnection is detected, recording the transmission progress of data transmission; the socket connection port of the electronic equipment is controlled to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port; recovering socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port; based on the restored socket connection and transmission progress, data transmission between the electronic equipment and the mobile terminal is continued, and based on the data transmission progress, reconnection is established through the switching port when socket connection disconnection is detected, so that data continuous transmission is realized, and the data transmission efficiency is improved.

Description

Data transmission method, device, storage medium and electronic equipment
Technical Field
The present application relates to the field of electronic device technologies, and in particular, to a data transmission method, an apparatus, a storage medium, and an electronic device.
Background
At present, terminals based on an Android system, such as mobile phones, tablet computers and the like, are widely applied to daily life of people. As the terminals are updated more and more frequently, the frequency of replacing the terminals by users is higher and higher, and the requirements for backing up and recovering the user information stored in the terminals are also increasing.
In a conventional backup scheme, a connection between a terminal and another device (e.g., a PC) is generally required to be established to backup and restore user information stored in the terminal, so as to transmit data of the terminal to the device for backup, and when necessary, restore the backed-up data to the terminal. However, when the amount of data to be backed up or restored is large, a long time is required for backup or restoration. In the process of data backup or recovery, once connection interruption occurs, data transmission fails, and due to lack of a disconnection reconnection mechanism, connection re-establishment is needed to start transmission again, so that more waiting time is added, and the data transmission efficiency is low.
Disclosure of Invention
The embodiment of the application provides a data transmission method, a data transmission device, a storage medium and electronic equipment, which can improve data transmission efficiency.
In a first aspect, an embodiment of the present application provides a data transmission method, which is applied to an electronic device, and the method includes:
data transmission is carried out between the electronic equipment and the mobile terminal through socket connection, wherein the socket connection is established between the electronic equipment and the mobile terminal;
when the socket connection disconnection is detected, recording the transmission progress of the data transmission;
controlling a socket connection port of the electronic equipment to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port;
restoring socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port;
and continuing to transmit data between the electronic equipment and the mobile terminal based on the recovered socket connection and the transmission progress.
In a second aspect, an embodiment of the present application further provides a data transmission apparatus, which is applied to an electronic device, and the method includes:
the data transmission unit is used for carrying out data transmission with the mobile terminal through socket connection, wherein the socket connection is established between the electronic equipment and the mobile terminal;
the progress recording unit is used for recording the transmission progress of the data transmission when the socket connection disconnection is detected;
the port switching unit is used for controlling the socket connection port of the electronic equipment to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port;
the connection management unit is used for recovering socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port;
and the data transmission unit is further used for continuing data transmission between the electronic equipment and the mobile terminal based on the recovered socket connection and the transmission progress.
In a third aspect, an embodiment of the present application further provides a storage medium, on which a computer program is stored, and when the computer program runs on a computer, the computer is caused to execute the data transmission method provided in any embodiment of the present application.
In a fourth aspect, an embodiment of the present application further provides an electronic device, which includes a processor and a memory, where the memory has a computer program, and the processor is configured to execute the data transmission method provided in any embodiment of the present application by calling the computer program.
According to the technical scheme provided by the embodiment of the application, data transmission between the electronic equipment and the mobile terminal is carried out through socket connection, and when socket connection disconnection is detected, the transmission progress of the data transmission is recorded; the socket connection port of the electronic equipment is controlled to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port; recovering socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port; the data transmission between the electronic equipment and the mobile terminal is continued based on the restored socket connection and transmission progress, through the scheme, when the socket connection disconnection between the electronic equipment and the mobile terminal is detected, the switching of the transmission ports is carried out to realize reconnection quickly, and the data transmission progress is saved when the connection is disconnected, so that the data transmission can be continued according to the recorded transmission progress after reconnection to improve the data transmission efficiency.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic flowchart of a data transmission method according to an embodiment of the present application.
Fig. 2 is a second flowchart of a data transmission method according to an embodiment of the present application.
Fig. 3 is a schematic structural diagram of a data transmission device according to an embodiment of the present application.
Fig. 4 is a first structural schematic diagram of an electronic device according to an embodiment of the present application.
Fig. 5 is a second structural schematic diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. It is to be understood that the embodiments described are only a few embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without inventive step, are within the scope of the present application.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
An execution main body of the data transmission method may be the data transmission device provided in the embodiment of the present application, or an electronic device integrated with the data transmission device, where the data transmission device may be implemented in a hardware or software manner. The electronic device may be a personal computer PC, a notebook computer, a server, or the like.
Referring to fig. 1, fig. 1 is a first flowchart illustrating a data transmission method according to an embodiment of the present disclosure. The specific process of the data transmission method provided by the embodiment of the application can be as follows:
101. and carrying out data transmission with the mobile terminal through socket connection, wherein the socket connection is established between the electronic equipment and the mobile terminal.
The embodiment of the present application takes an electronic device as an example for explanation. The scheme of the embodiment of the application can be applied to backup of data on the mobile terminal to the PC terminal, and can also be applied to scenes that data transmission between two devices is needed such as recovery of data stored on the PC terminal to the mobile terminal.
When the data on the mobile terminal is backed up to the PC end, the mobile terminal is a data sending end, and the PC end is a data receiving end. When the data stored on the PC end is restored to the mobile terminal, the PC end is a data sending end, and the mobile terminal is a data receiving end.
In the embodiment of the application, the electronic device is connected with the mobile terminal through a Universal Serial Bus (USB) data line, so that the mobile terminal is connected with the electronic device through a socket interface of an Android Debug Bridge (ADB), and after the socket connection is established, a communication protocol supported by the ADB interface is used between the electronic device and the mobile terminal to perform signaling interaction and data transmission.
The Protocol for performing communication between the electronic device and the mobile terminal may be an existing communication Protocol, such as a TCP/IP (transmission Control Protocol, transmission Control Protocol/Internet Protocol, Internet Protocol), or may be a Protocol in a certain format agreed between the electronic device and the mobile terminal, as long as the Protocol is a communication Protocol that can be supported by an ADB interface.
The electronic equipment calls an ADB forward instruction through an ADB interface, and Socket connection between the electronic equipment and the mobile terminal is established. And the electronic equipment sends or receives signaling and data through a socket port specified in the adb forward command. For example, the adb forward instruction is an adb forward tcp:2320tcp 1220;
the port 2320 is used as a Socket port of the electronic device, and the electronic device sends an instruction or transmits data to the mobile terminal through the port and/or receives the instruction or data sent by the mobile terminal through the port; the port 1220 is used as a Socket port of the mobile terminal, through which the mobile terminal listens for commands or data from the electronic device and/or sends commands or data to the electronic device, and for the Socket connection, the mobile terminal is equivalent to a server and the electronic device is equivalent to a client.
In the data transmission process, the data sending end determines data to be sent, wherein the data to be transmitted can be selected manually by a user, or the data sending end obtains data matched with the data type from the data sending end or from a specified path of the data sending end according to the data type set by the user and takes the data as the data to be transmitted.
In some embodiments, the method may further comprise: and when receiving data or an instruction sent by the mobile terminal, sending a receiving receipt to the mobile terminal, wherein if the mobile terminal does not receive the receiving receipt after sending the data or the instruction, the socket connection is judged to be disconnected.
After the data sending end sends data or some specific instructions to the data receiving end, if the data receiving end receives the data or the instructions, a receipt is sent to the data sending end immediately. And if the data sending end does not receive the receipt sent by the data receiving end for a long time, judging that the socket connection between the electronic equipment and the mobile terminal is disconnected.
It can be understood that, when the mobile terminal is a data receiving terminal, if the electronic device does not receive a receipt sent by the data receiving terminal for a long time, it is determined that the socket connection between the electronic device and the mobile terminal has been disconnected. When the electronic equipment is a data receiving end, if the mobile terminal does not receive a receiving receipt sent by the data receiving end for a long time, a prompt message is sent to the electronic equipment through the ADB interface to inform that the socket connection of the electronic equipment is disconnected, and when the electronic equipment receives the prompt message, the socket connection between the electronic equipment and the mobile terminal can be determined to be disconnected.
102. And recording the transmission progress of the data transmission when the socket connection disconnection is detected.
And when the electronic equipment detects that the socket is disconnected, recording the transmission progress of the current data transmission. When the data sending end sends data, a number is created for each file, all files to be sent are sorted according to the numbers, a field mark is added to each file, and the field mark is used for indicating whether the file is transmitted to the data receiving end or not. For example, if the file has been transmitted to the data receiving end, the value of the field identifier is modified to 1, and the value of the field identifier of the file that has not been transmitted in the file list is still 0.
When the socket connection is disconnected, both the data sending end and the data receiving end can record the current data transmission progress. The transmission progress information recorded by the data sending end includes a file sending state list, and the file sending state list can be determined according to the field identification in the file list. The transmission progress information recorded by the data receiving end comprises file information of the last received file and the received length of the file, and the file information of the last received file is the information of the file being received when the socket connection is disconnected.
103. And controlling a socket connection port of the electronic equipment to be switched to a first standby port from a first preset port, wherein the socket connection port of the mobile terminal is switched to a second standby port from a second preset port.
104. And recovering the socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port.
When the socket connection disconnection is detected, the electronic equipment can also switch the communication port. In general, a socket connection is disconnected, which may be caused by network abnormality or port occupation. The network anomaly is not a generalized network anomaly, and after the electronic equipment and the mobile terminal establish a communication protocol based on an ADB interface, a small local area network is established, and the network anomaly refers to the fact that the local area network is abnormal. In addition, since other processes running in the electronic device may use the port, especially when some processes with higher priority occupy the port, the port used by the socket connection is occupied. All of the above causes the socket connection to be disconnected.
At this time, in order to ensure the continuous transmission of data, socket port switching is performed. In the data transmission process, the port initially used by the electronic device is a first preset port, and the port initially used by the mobile terminal is a second preset port. In addition, a first standby port is preset for the electronic equipment, and a second standby port is preset for the mobile terminal.
And controlling a socket connection port of the electronic equipment to be switched to a first standby port from a first preset port, wherein the socket connection port of the mobile terminal is switched to a second standby port from a second preset port.
And after the switching of the first standby port and the second standby port is completed, reconnection of socket connection is realized based on the switched ports.
105. And continuing to transmit data between the electronic equipment and the mobile terminal based on the recovered socket connection and the transmission progress.
After the socket connection is recovered, the data transmission progress is saved when the connection is disconnected, so that the data transmission can be continued according to the recorded transmission progress after reconnection.
In particular implementation, the present application is not limited by the execution sequence of the described steps, and some steps may be performed in other sequences or simultaneously without conflict.
As can be seen from the above, in the data transmission method provided in the embodiment of the present application, data transmission between the electronic device and the mobile terminal is performed through socket connection, and when it is detected that the socket connection is disconnected, a transmission progress of the data transmission is recorded; the socket connection port of the electronic equipment is controlled to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port; recovering socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port; the data transmission between the electronic equipment and the mobile terminal is continued based on the restored socket connection and transmission progress, through the scheme, when the socket connection disconnection between the electronic equipment and the mobile terminal is detected, the switching of the transmission ports is carried out to realize reconnection quickly, and the data transmission progress is saved when the connection is disconnected, so that the data transmission can be continued according to the recorded transmission progress after reconnection to improve the data transmission efficiency.
In some embodiments, to improve the utilization rate of the port, before the socket connection port controlling the electronic device is switched from the first preset port to the first standby port, the method may further include: when the socket connection disconnection is detected, sending a first connection instruction to the mobile terminal based on the first preset port so as to reconnect with the mobile terminal; and if the reconnection fails, executing control to switch the socket connection port of the electronic equipment from a first preset port to a first standby port.
Because socket connection and disconnection can be caused by various reasons, when socket connection and disconnection are detected, reconnection based on the current port can be tried, if reconnection fails, switching of the port is carried out again, so that the utilization rate of the port is improved, and the situation that the port of other processes is occupied and the operation of other processes is influenced while data transmission is guaranteed is avoided.
In some embodiments, continuing data transmission between the electronic device and the mobile terminal based on the restored socket connection and the transmission progress includes: when the data transmission is data backup, determining the last received file information according to the transmission progress, and sending the last received file information to the mobile terminal, wherein the mobile terminal continues to backup the data to the electronic equipment based on the last received file information; and when the data transmission is data recovery, determining the file information received last according to the transmission progress, and continuously sending the data to the mobile terminal according to the file information received last.
The data recovery transmission process is different for different data transmission scenes.
When data backup is carried out, the electronic equipment is a data receiving end, and the transmission progress information recorded by the electronic equipment comprises file information of a last received file and the received length of the file. The mobile terminal is a data sending end, and the mobile terminal records a file sending state list. Therefore, after the socket connection is restored, the electronic device determines the last received file information according to the transmission progress, and sends the last received file information to the mobile terminal, so that the mobile terminal can continuously back up the data to the electronic device based on the last received file information.
On the contrary, when data recovery is performed, the electronic device is a data sending end, and the electronic device records a file sending state list. The mobile terminal is a data receiving terminal, and the transmission progress information recorded by the mobile terminal comprises file information of the last received file and the received length of the file. Therefore, after the socket connection is recovered, the electronic device can directly determine the file information received last according to the transmission progress, and continuously send the data to the mobile terminal according to the file information received last.
It should be noted that, in other embodiments, the data sender may record both the file sending status list and the file information of the last received file, as well as the received length of the file.
The method according to the preceding embodiment is illustrated in further detail below by way of example.
Referring to fig. 2, fig. 2 is a second flow chart of a data transmission method according to an embodiment of the invention. The method comprises the following steps:
201. and carrying out data transmission with the mobile terminal through socket connection, wherein the socket connection is established between the electronic equipment and the mobile terminal.
The scheme of the embodiment of the application can be applied to backup of data on the mobile terminal to the PC terminal, and can also be applied to scenes that data transmission between two devices is needed such as recovery of data stored on the PC terminal to the mobile terminal. When the data on the mobile terminal is backed up to the PC end, the mobile terminal is a data sending end, and the PC end is a data receiving end. When the data stored on the PC end is restored to the mobile terminal, the PC end is a data sending end, and the mobile terminal is a data receiving end.
The electronic equipment is connected with the mobile terminal through the USB data line, so that the mobile terminal is connected with the electronic equipment through a socket established between the mobile terminal and the electronic equipment through an ADB interface, and after the socket connection is established, signaling interaction and data transmission are carried out between the electronic equipment and the mobile terminal through a communication protocol supported by the ADB interface.
202. And recording the transmission progress of the data transmission when the socket connection disconnection is detected.
When the socket connection disconnection is detected, both the data sending end and the data receiving end can record the current data transmission progress. The transmission progress information recorded by the data sending end includes a file sending state list, and the file sending state list can be determined according to the field identification in the file list. The transmission progress information recorded by the data receiving end comprises file information of the last received file and the received length of the file, and the file information of the last received file is the information of the file being received when the socket connection is disconnected.
203. And sending a first connection instruction to the mobile terminal based on the first preset port so as to reconnect with the mobile terminal.
If the reconnect fails, 204 is performed.
If the reconnect is successful, 207 is performed.
204. And judging whether the reconnection times are greater than the preset times.
In order to improve the utilization rate of the port, when it is detected that socket connection is disconnected, reconnection based on the current port may be attempted first, where the reconnection number may be multiple times, for example, an upper limit value of the reconnection number is set as a preset number, time of each reconnection is a first preset duration, that is, if reconnection does not succeed within the first preset duration after a first connection instruction is sent to the mobile terminal based on the first preset port, it is determined that reconnection fails this time. Otherwise, the reconnection is determined to be successful, and the specific first preset time and the preset times can be set according to needs, for example, the first preset time is 5-15s, and the preset times is 3-8.
And if the reconnection times are not more than the preset times, returning to execute 203.
If the number of reconnects is greater than the predetermined number, 205 is performed.
205. And controlling a socket connection port of the electronic equipment to be switched to a first standby port from a first preset port, wherein the socket connection port of the mobile terminal is switched to a second standby port from a second preset port.
If the reconnection fails after multiple reconnection attempts, the ports are switched, and the specific switching manner refers to the above embodiments and is not described herein again.
It can be understood that, if the socket connection is to be successfully established, it is assumed that the electronic device and the mobile terminal are still connected through the USB data line, and therefore, after the socket connection disconnection is detected, it is first detected whether the mobile terminal is still connected to the electronic device, which may be detected through the ADB connection state. If yes, switching the ports.
In addition, since the electronic device is the party that actively initiates the socket connection, the mobile terminal is the party that waits for the connection. Therefore, after waiting for the second preset duration, if the reconnection is still not successful, the mobile terminal switches the port from the second preset port to the second standby port. And the second preset time length is equal to the product of the first preset time length and the preset times.
206. And recovering the socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port.
In some embodiments, restoring the socket connection between the electronic device and the mobile terminal based on the first backup port and the second backup port may include: determining a first standby port of the electronic equipment and a second standby port of the mobile terminal; generating a second connection instruction according to the first standby port and the second standby port; and sending the second connection instruction to the mobile terminal so as to recover the socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port.
After the ports are switched, a connection instruction is regenerated based on the switched ports, and the connection instruction is sent to the mobile terminal by the electronic equipment so as to reestablish socket connection.
207. And continuing to transmit data between the electronic equipment and the mobile terminal based on the recovered socket connection and the transmission progress.
In some embodiments, after the socket connection between the electronic device and the mobile terminal is restored based on the first standby port and the second standby port, the method may further include: if the socket connection is successfully restored, executing data transmission between the electronic equipment and the mobile terminal based on the restored socket connection and the transmission progress; and if the socket connection recovery fails, determining a new first standby port from the plurality of preset ports of the electronic equipment again, and returning to execute control to switch the socket connection port of the electronic equipment from the first preset port to the first standby port.
In this embodiment, a plurality of standby ports may be preset, for example, two standby ports are respectively set for the electronic device and the mobile terminal, if the switched first standby port still cannot be successfully connected, the switched first standby port is switched to the second standby port to try reconnection, and reconnection is abandoned until all the standby ports cannot be successfully reconnected, so as to prompt the user to disconnect the connection.
As can be seen from the above, in the data transmission method provided in the embodiment of the present invention, when it is detected that the socket connection between the electronic device and the mobile terminal is disconnected, the data transmission method attempts to establish a connection with the mobile terminal again based on the current port. When reconnection fails, the transfer ports are switched to realize reconnection quickly, and the data transfer progress is saved when the connection is disconnected, so that data transfer can be continued according to the recorded data transfer progress after reconnection, and the data transfer efficiency is improved.
In one embodiment, a data transmission device is also provided. Referring to fig. 3, fig. 3 is a schematic structural diagram of a data transmission device 300 according to an embodiment of the present disclosure. The data transmission apparatus 300 is applied to an electronic device, and the data transmission apparatus 300 includes a data transmission unit 301, a progress recording unit 302, a port switching unit 303, and a connection management unit 304, as follows:
the data transmission unit 301 is configured to perform data transmission with a mobile terminal through a socket connection, where the socket connection is established between the electronic device and the mobile terminal;
the progress recording unit 302 is used for recording the transmission progress of the data transmission when the socket connection disconnection is detected;
a port switching unit 303, configured to control a socket connection port of the electronic device to be switched from a first preset port to a first standby port, where a socket connection port of the mobile terminal is switched from a second preset port to a second standby port;
a connection management unit 304, configured to restore socket connection between the electronic device and the mobile terminal based on the first standby port and the second standby port;
the data transmission unit 301 is further configured to continue data transmission between the electronic device and the mobile terminal based on the recovered socket connection and the transmission progress.
In some embodiments, the connection management unit 304 is further configured to: when the socket connection disconnection is detected, sending a first connection instruction to the mobile terminal based on the first preset port so as to reconnect with the mobile terminal;
the port switching unit 303 is further configured to: and if the reconnection fails, controlling the socket connection port of the electronic equipment to be switched from a first preset port to a first standby port.
In some embodiments, the connection management unit 304 is further configured to: if the reconnection fails, judging whether the reconnection times are greater than preset times;
if the reconnection times are not more than the preset times, returning to execute the sending of a first connection instruction to the mobile terminal based on the first preset port so as to reconnect with the mobile terminal;
the port switching unit 303 is further configured to: and if the reconnection times are greater than the preset times, controlling the socket connection port of the electronic equipment to be switched from the first preset port to the first standby port.
In some embodiments, the connection management unit 304 is further configured to: determining a first standby port of the electronic equipment and a second standby port of the mobile terminal;
generating a second connection instruction according to the first standby port and the second standby port;
and sending the second connection instruction to the mobile terminal so as to recover the socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port.
In some embodiments, the connection management unit 304 is further configured to: if the socket connection is successfully restored, executing data transmission between the electronic equipment and the mobile terminal based on the restored socket connection and the transmission progress;
the port switching unit 303 is further configured to: and if the socket connection recovery fails, determining a new first standby port from the plurality of preset ports of the electronic equipment again, and returning to execute control to switch the socket connection port of the electronic equipment from the first preset port to the first standby port.
In some embodiments, the data transmission unit 301 is further configured to: when the data transmission is data backup, determining the last received file information according to the transmission progress, and sending the last received file information to the mobile terminal, wherein the mobile terminal continues to backup the data to the electronic equipment based on the last received file information;
and when the data transmission is data recovery, determining the file information received last according to the transmission progress, and continuously sending the data to the mobile terminal according to the file information received last.
In specific implementation, the above modules may be implemented as independent entities, or may be combined arbitrarily to be implemented as the same or several entities, and specific implementation of the above modules may refer to the foregoing method embodiments, which are not described herein again.
It should be noted that the data transmission device provided in the embodiment of the present application and the data transmission method in the foregoing embodiment belong to the same concept, and any method provided in the data transmission method embodiment may be executed on the data transmission device, and a specific implementation process thereof is described in detail in the data transmission method embodiment, and is not described herein again.
As can be seen from the above, in the data transmission device provided in this embodiment of the application, the data transmission unit 301 performs data transmission between the electronic device and the mobile terminal through socket connection, and when it is detected that the socket connection is disconnected, the progress recording unit 302 records the transmission progress of the data transmission; the port switching unit 303 controls the socket connection port of the electronic device to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port; the connection management unit 304 recovers socket connection between the electronic device and the mobile terminal based on the first standby port and the second standby port; data transmission unit 301 continues to carry out data transmission between electronic equipment and the mobile terminal based on the socket connection and the transmission progress after the recovery, and through this scheme, when detecting the socket disconnection between electronic equipment and the mobile terminal, carry out the switching of transmission port in order to realize reconnection fast, owing to saved the data transmission progress when the disconnection, consequently, can continue to carry out the transmission of data according to the transmission progress of record after reconnection to improve data transmission efficiency.
The embodiment of the application also provides the electronic equipment. The electronic device can be a smart phone, a tablet computer and the like. Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. The electronic device 400 comprises a processor 401 and a memory 402. The processor 401 is electrically connected to the memory 402.
The processor 401 is a control center of the electronic device 400, connects various parts of the entire electronic device using various interfaces and lines, and performs various functions of the electronic device and processes data by running or calling a computer program stored in the memory 402 and calling data stored in the memory 402, thereby performing overall monitoring of the electronic device.
Memory 402 may be used to store computer programs and data. The memory 402 stores computer programs containing instructions executable in the processor. The computer program may constitute various functional modules. The processor 401 executes various functional applications and data processing by calling a computer program stored in the memory 402.
In this embodiment, the processor 401 in the electronic device 400 loads instructions corresponding to one or more processes of the computer program into the memory 402 according to the following steps, and the processor 401 runs the computer program stored in the memory 402, so as to implement various functions:
data transmission is carried out between the electronic equipment and the mobile terminal through socket connection, wherein the socket connection is established between the electronic equipment and the mobile terminal;
when the socket connection disconnection is detected, recording the transmission progress of the data transmission;
controlling a socket connection port of the electronic equipment to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port;
restoring socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port;
and continuing to transmit data between the electronic equipment and the mobile terminal based on the recovered socket connection and the transmission progress.
In some embodiments, please refer to fig. 5, and fig. 5 is a second structural diagram of an electronic device according to an embodiment of the present disclosure. The electronic device 400 further comprises: radio frequency circuit 403, display 404, control circuit 405, input unit 406, audio circuit 407, sensor 408, and power supply 409. The processor 401 is electrically connected to the radio frequency circuit 403, the display 404, the control circuit 405, the input unit 406, the audio circuit 407, the sensor 408, and the power source 409.
The radio frequency circuit 403 is used for transceiving radio frequency signals to communicate with a network device or other electronic devices through wireless communication.
The display screen 404 may be used to display information entered by or provided to the user as well as various graphical user interfaces of the electronic device, which may be comprised of images, text, icons, video, and any combination thereof.
The control circuit 405 is electrically connected to the display screen 404, and is configured to control the display screen 404 to display information.
The input unit 406 may be used to receive input numbers, character information, or user characteristic information (e.g., fingerprint), and to generate keyboard, mouse, joystick, optical, or trackball signal inputs related to user settings and function control. The input unit 406 may include a fingerprint recognition module.
The audio circuit 407 may provide an audio interface between the user and the electronic device through a speaker, microphone. Wherein the audio circuit 407 comprises a microphone. The microphone is electrically connected to the processor 401. The microphone is used for receiving voice information input by a user.
The sensor 408 is used to collect external environmental information. The sensors 408 may include one or more of ambient light sensors, acceleration sensors, gyroscopes, etc.
The power supply 409 is used to power the various components of the electronic device 400. In some embodiments, the power source 409 may be logically connected to the processor 401 through a power management system, so that functions of managing charging, discharging, and power consumption are implemented through the power management system.
Although not shown in the drawings, the electronic device 400 may further include a camera, a bluetooth module, and the like, which are not described in detail herein.
In this embodiment, the processor 401 in the electronic device 400 loads instructions corresponding to one or more processes of the computer program into the memory 402 according to the following steps, and the processor 401 runs the computer program stored in the memory 402, so as to implement various functions:
data transmission is carried out between the electronic equipment and the mobile terminal through socket connection, wherein the socket connection is established between the electronic equipment and the mobile terminal;
when the socket connection disconnection is detected, recording the transmission progress of the data transmission;
controlling a socket connection port of the electronic equipment to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port;
restoring socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port;
and continuing to transmit data between the electronic equipment and the mobile terminal based on the recovered socket connection and the transmission progress.
Therefore, the electronic equipment performs data transmission between the electronic equipment and the mobile terminal through socket connection, and records the transmission progress of the data transmission when the socket connection is detected to be disconnected; the socket connection port of the electronic equipment is controlled to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port; recovering socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port; the data transmission between the electronic equipment and the mobile terminal is continued based on the restored socket connection and transmission progress, through the scheme, when the socket connection disconnection between the electronic equipment and the mobile terminal is detected, the switching of the transmission ports is carried out to realize reconnection quickly, and the data transmission progress is saved when the connection is disconnected, so that the data transmission can be continued according to the recorded transmission progress after reconnection to improve the data transmission efficiency.
An embodiment of the present application further provides a storage medium, where a computer program is stored in the storage medium, and when the computer program runs on a computer, the computer executes the data transmission method according to any of the above embodiments.
It should be noted that, all or part of the steps in the methods of the above embodiments may be implemented by hardware related to instructions of a computer program, which may be stored in a computer-readable storage medium, which may include, but is not limited to: read Only Memory (ROM), Random Access Memory (RAM), magnetic or optical disks, and the like.
Furthermore, the terms "first", "second", and "third", etc. in this application are used to distinguish different objects, and are not used to describe a particular order. Furthermore, the terms "include" and "have," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or modules is not limited to only those steps or modules listed, but rather, some embodiments may include other steps or modules not listed or inherent to such process, method, article, or apparatus.
The data transmission method, the data transmission device, the storage medium, and the electronic device provided in the embodiments of the present application are described in detail above. The principle and the implementation of the present application are explained herein by applying specific examples, and the above description of the embodiments is only used to help understand the method and the core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A data transmission method, applied to an electronic device, the method comprising:
data transmission is carried out between the electronic equipment and the mobile terminal through socket connection, wherein the socket connection is established between the electronic equipment and the mobile terminal;
when the socket connection disconnection is detected, recording the transmission progress of the data transmission;
controlling a socket connection port of the electronic equipment to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port;
restoring socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port;
and continuing to transmit data between the electronic equipment and the mobile terminal based on the recovered socket connection and the transmission progress.
2. The data transmission method according to claim 1, wherein before the socket connection port controlling the electronic device is switched from the first preset port to the first standby port, the method further comprises:
when the socket connection disconnection is detected, sending a first connection instruction to the mobile terminal based on the first preset port so as to reconnect with the mobile terminal;
and if the reconnection fails, executing control to switch the socket connection port of the electronic equipment from a first preset port to a first standby port.
3. The data transmission method according to claim 2, wherein before the socket connection port controlling the electronic device is switched from the first preset port to the first standby port, the method further comprises:
if the reconnection fails, judging whether the reconnection times are greater than preset times;
if the reconnection times are not more than the preset times, returning to execute the sending of a first connection instruction to the mobile terminal based on the first preset port so as to reconnect with the mobile terminal;
and if the reconnection times are greater than the preset times, executing control to switch the socket connection port of the electronic equipment from a first preset port to a first standby port.
4. The data transmission method according to claim 1, wherein the restoring the socket connection between the electronic device and the mobile terminal based on the first backup port and the second backup port comprises:
determining a first standby port of the electronic equipment and a second standby port of the mobile terminal;
generating a second connection instruction according to the first standby port and the second standby port;
and sending the second connection instruction to the mobile terminal so as to recover the socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port.
5. The data transmission method according to claim 1, wherein after the recovering of the socket connection between the electronic device and the mobile terminal based on the first backup port and the second backup port, the method further comprises:
if the socket connection is successfully restored, executing data transmission between the electronic equipment and the mobile terminal based on the restored socket connection and the transmission progress;
and if the socket connection recovery fails, determining a new first standby port from the plurality of preset ports of the electronic equipment again, and returning to execute control to switch the socket connection port of the electronic equipment from the first preset port to the first standby port.
6. The data transmission method according to any one of claims 1 to 5, wherein the continuing of the data transmission between the electronic device and the mobile terminal based on the restored socket connection and the transmission progress includes:
when the data transmission is data backup, determining the last received file information according to the transmission progress, and sending the last received file information to the mobile terminal, wherein the mobile terminal continues to backup the data to the electronic equipment based on the last received file information;
and when the data transmission is data recovery, determining the file information received last according to the transmission progress, and continuously sending the data to the mobile terminal according to the file information received last.
7. A data transmission apparatus, applied to an electronic device, the apparatus comprising:
the data transmission unit is used for carrying out data transmission with the mobile terminal through socket connection, wherein the socket connection is established between the electronic equipment and the mobile terminal;
the progress recording unit is used for recording the transmission progress of the data transmission when the socket connection disconnection is detected;
the port switching unit is used for controlling the socket connection port of the electronic equipment to be switched from a first preset port to a first standby port, wherein the socket connection port of the mobile terminal is switched from a second preset port to a second standby port;
the connection management unit is used for recovering socket connection between the electronic equipment and the mobile terminal based on the first standby port and the second standby port;
and the data transmission unit is further used for continuing data transmission between the electronic equipment and the mobile terminal based on the recovered socket connection and the transmission progress.
8. The data transmission apparatus of claim 7, wherein the connection management unit is further configured to: when the socket connection disconnection is detected, sending a first connection instruction to the mobile terminal based on the first preset port so as to reconnect with the mobile terminal;
the port switching unit is further configured to: and if the reconnection fails, controlling the socket connection port of the electronic equipment to be switched from a first preset port to a first standby port.
9. A storage medium having stored thereon a computer program, characterized in that, when the computer program is run on a computer, it causes the computer to execute a data transmission method according to any one of claims 1 to 6.
10. An electronic device comprising a processor and a memory, the memory storing a computer program, wherein the processor is configured to execute the data transfer method according to any one of claims 1 to 6 by calling the computer program.
CN202010125417.6A 2020-02-27 2020-02-27 Data transmission method, device, storage medium and electronic equipment Active CN111328155B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010125417.6A CN111328155B (en) 2020-02-27 2020-02-27 Data transmission method, device, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010125417.6A CN111328155B (en) 2020-02-27 2020-02-27 Data transmission method, device, storage medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN111328155A CN111328155A (en) 2020-06-23
CN111328155B true CN111328155B (en) 2022-01-07

Family

ID=71171200

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010125417.6A Active CN111328155B (en) 2020-02-27 2020-02-27 Data transmission method, device, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN111328155B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105120009A (en) * 2015-09-14 2015-12-02 百度在线网络技术(北京)有限公司 Terminal interconnection method and device
CN106302808A (en) * 2016-09-14 2017-01-04 广东欧珀移动通信有限公司 Data transmission method and mobile terminal
CN107172060A (en) * 2017-06-06 2017-09-15 武汉票据交易中心有限公司 A kind of login method of client container
CN108075947A (en) * 2017-07-31 2018-05-25 北京微应软件科技有限公司 The connective maintaining method of storage device, PC ends, communication connection and system
CN109726129A (en) * 2018-12-29 2019-05-07 北京小米移动软件有限公司 Code segment operation method, device, terminal and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105120009A (en) * 2015-09-14 2015-12-02 百度在线网络技术(北京)有限公司 Terminal interconnection method and device
CN106302808A (en) * 2016-09-14 2017-01-04 广东欧珀移动通信有限公司 Data transmission method and mobile terminal
CN107172060A (en) * 2017-06-06 2017-09-15 武汉票据交易中心有限公司 A kind of login method of client container
CN108075947A (en) * 2017-07-31 2018-05-25 北京微应软件科技有限公司 The connective maintaining method of storage device, PC ends, communication connection and system
CN109726129A (en) * 2018-12-29 2019-05-07 北京小米移动软件有限公司 Code segment operation method, device, terminal and storage medium

Also Published As

Publication number Publication date
CN111328155A (en) 2020-06-23

Similar Documents

Publication Publication Date Title
CN111246441B (en) Method, system and storage medium for connecting Bluetooth headset and terminal
US7076269B2 (en) Radio communication system for notifying incommunicable state, and device and method used for the system
EP3547715B1 (en) Method and apparatus for reducing continuous-wakeup delay of bluetooth loudspeaker, and bluetooth loudspeaker
JP4510720B2 (en) Method for detecting external device of mobile communication terminal
WO2019112268A1 (en) Method and device for reconnecting bluetooth communication
CN105302673A (en) Information backup method and device and terminal
CN105573845A (en) Information processing method and system and terminals
CN102859975A (en) Communication terminal and application control method
CN111262941B (en) Method for reconnecting cloud server and electronic equipment
CN111263467B (en) Wireless connection switching method, wireless terminal and system thereof
WO2016119329A1 (en) Terminal controlling method, terminal controlling device and terminal
CN106060280B (en) Data service management method, device and terminal
JP6785332B2 (en) Bluetooth speaker Data processing method, device and bluetooth speaker
CN113609107A (en) Database management method and device, electronic equipment and storage medium
CN112486733B (en) System restoration method, device, terminal and storage medium
CN111328155B (en) Data transmission method, device, storage medium and electronic equipment
CN110944313B (en) Bluetooth connection method, device, storage medium and terminal
CN113810890A (en) Device loop-back method, device, electronic device and storage medium
CN113412480B (en) Mounting processing method, mounting processing device, electronic equipment and computer readable storage medium
CN111352959A (en) Data synchronization remediation and storage method and cluster device
CN112491810B (en) Data connection method and mobile terminal
WO2019237954A1 (en) Network connection method and device, readable storage medium and intelligent terminal
CN111969686A (en) Mobile terminal for concurrent USB OTG and charging and implementation method
CN101661445A (en) Connection switching method, device and system
CN111885591A (en) Network connection method, device, storage medium and terminal

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