Data transmission method, device and system and electronic equipment
By setting up a proxy server between devices and using USB protocol to simulate wireless transmission, the problem of USB protocol adaptation in cross-device communication is solved, the portability and compatibility of services are improved, and the development difficulty is reduced.
Patent Information
- Application Number
- CN202510181818.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-19
- Publication Date
- 2025-06-10
AI Technical Summary
When communicating across devices, business developers need to adapt to the USB protocol, resulting in poor portability and compatibility of the solution and increasing the difficulty of development.
By setting up a client and a local proxy server in the first device and the second device, the data to be transmitted from the first device to the second device is transmitted from the first device to the second device using the USB protocol, simulating wireless transmission.
It improves the portability and compatibility of the upper-level services corresponding to the client, reduces the difficulty of development, and makes business developers not need to care about the underlying transmission protocol.
Smart Images

Figure CN120128631A_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of communication technologies, and in particular, to a data transmission method, apparatus, system, and electronic device. Background Art
[0002] When communicating across devices, a Universal Serial Bus (USB) can be used as a physical connection means between two devices. In this case, when wireless transmission or screen mirroring is required between two devices, the following problems may exist: When determining a service implementation solution, service developers need to adapt to the USB protocol, making the portability and compatibility of the solution very poor; and when adapting to the USB protocol, service developers need to understand the content of the USB protocol, increasing the development difficulty. Summary of the Invention
[0003] The present invention provides a data transmission method, apparatus, system, and electronic device, which can simulate the USB protocol as a wireless transmission, increasing the portability and compatibility of the upper-layer services corresponding to the client, and at the same time reducing the development difficulty.
[0004] In a first aspect, an embodiment of the present invention provides a data transmission method, which is applied to a first device. The method includes:
[0005] Establishing a communication connection between a first client in the first device and a first local proxy server in the first device;
[0006] Transmitting data to be transmitted to the first local proxy server through the first client; wherein, the data to be transmitted includes data that the first client needs to transmit to a second client in a second device in a wireless transmission manner; the first device and the second device are connected through a Universal Serial Bus (USB);
[0007] Transmitting the data to be transmitted to a second local proxy server in the second device based on the USB protocol through the first local proxy server, so that the second client can obtain the data to be transmitted from the second local proxy server.
[0008] In a second aspect, an embodiment of the present invention provides a data transmission method, which is applied to a second device. The method includes:
[0009] Establishing a communication connection between a second client in the second device and a second local proxy server in the second device;
[0010] Through the second local proxy server, obtain the data to be transmitted transmitted by the first local proxy server in the first device based on the Universal Serial Bus (USB) protocol; wherein, the data to be transmitted includes the data that the first client in the first device needs to transmit to the second client in a wireless transmission manner; the first device and the second device are connected through USB.
[0011] Through the second client, obtain the data to be transmitted from the second local proxy server.
[0012] In a third aspect, an embodiment of the present invention provides a data transmission device configured in a first device, and the device includes:
[0013] A first processing module, configured to establish a communication connection with a first local proxy server in the first device through a first client in the first device;
[0014] A second processing module, configured to transmit data to be transmitted to the first local proxy server through the first client; wherein, the data to be transmitted includes the data that the first client needs to transmit to a second client in a second device in a wireless transmission manner; the first device and the second device are connected through a Universal Serial Bus (USB).
[0015] A third processing module, configured to transmit the data to be transmitted to a second local proxy server in the second device based on the USB protocol through the first local proxy server, so that the second client can obtain the data to be transmitted from the second local proxy server.
[0016] In a fourth aspect, an embodiment of the present invention provides a data transmission device configured in a second device, and the device includes:
[0017] A fourth processing module, configured to establish a communication connection with a second local proxy server in the second device through a second client in the second device;
[0018] A fifth processing module, configured to obtain the data to be transmitted transmitted by the first local proxy server in the first device based on the Universal Serial Bus (USB) protocol through the second local proxy server; wherein, the data to be transmitted includes the data that the first client in the first device needs to transmit to the second client in a wireless transmission manner; the first device and the second device are connected through USB.
[0019] A sixth processing module, configured to obtain the data to be transmitted from the second local proxy server through the second client.
[0020] Fifth aspect, an embodiment of the present invention provides a data transmission system, including: a first device and a second device; wherein, the first device is configured to execute the method described in the first aspect; the second device is configured to execute the method described in the second aspect.
[0021] Sixth aspect, an embodiment of the present invention provides an electronic device, including:
[0022] at least one processor; and
[0023] a memory communicatively connected to the at least one processor; wherein,
[0024] the memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the at least one processor is enabled to execute the method described in the first aspect, or execute the method described in the second aspect.
[0025] Seventh aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the method described in the first aspect, or implements the method described in the second aspect.
[0026] In the technical solution of the embodiment of the present invention, a first client and a first local proxy server are included in the first device, a second client and a second local proxy server are included in the second device, and the first device and the second device are connected through USB; the first client transmits the data to be transmitted that needs to be transmitted to the second client in a wireless transmission manner to the first local proxy server; the first local proxy server transmits the data to be transmitted to the second local proxy server based on the USB protocol, and the second client can obtain the data to be transmitted from the second local proxy server. This solution can simulate the USB protocol as a wireless transmission, that is, through the communication between the first client and the first local proxy server, the communication between the second client and the second local proxy server, and the communication between the first local proxy server and the second local proxy server based on the USB protocol, to simulate the wireless communication between the first client and the second client; business developers do not need to care whether it is based on the USB protocol transmission or wireless transmission at the underlying layer, and can be adapted through wireless transmission, increasing the portability and compatibility of the upper-layer services corresponding to the client; business developers do not need to understand the content of the USB protocol, reducing the development difficulty.
[0027] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] To more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0029] Figure 1 is a flowchart of a data transmission method provided in Embodiment 1 of the present invention;
[0030] Figure 2 is a flowchart of a data transmission method provided in Embodiment 2 of the present invention;
[0031] Figure 3 is a schematic structural diagram of a data transmission device provided in Embodiment 3 of the present invention;
[0032] Figure 4 is a schematic structural diagram of a data transmission device provided in Embodiment 4 of the present invention;
[0033] Figure 5 is a schematic structural diagram of a data transmission system provided in Embodiment 5 of the present invention;
[0034] Figure 6 is a schematic structural diagram of an electronic device implementing the embodiments of the present invention. Detailed Embodiments
[0035] In order to enable those skilled in the art to better understand the solutions of the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only 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 shall fall within the protection scope of the present invention.
[0036] It should be noted that the terms "first", "second", etc. in the present invention are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances, so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily need to be limited to those clearly listed steps or units, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0037] Example 1
[0038] Figure 1 FIG. 0000085 is a flowchart of a data transmission method provided according to Example 1 of the present invention. This example is applicable to the situation where a first device sends data to be transmitted to a second device. This method can be executed by a data transmission device, which can be implemented in the form of software and / or hardware and integrated in an electronic device serving as the first device. Further, the electronic device includes, but is not limited to, a computer, a laptop computer, etc.
[0039] As Figure 1 shown, the method includes:
[0040] S110. Establish a communication connection with a first local proxy server in the first device through a first client in the first device.
[0041] The first client can be a client in the first device. The client can be a running instance of an application program on the electronic device, responsible for receiving data, presenting data, and processing user input and interaction.
[0042] The first local proxy server can be a proxy server created locally in the first device. In the embodiments of the present invention, the proxy server can be understood as a computer system or software service between the client and the end actually communicating with the client. The proxy server can intercept the data transmitted by the client when the client transmits data to the end actually communicating, and transmit the intercepted data through the proxy server. Among them, the end actually communicating with the client can be a client in a device different from the first device.
[0043] In this step, the first device includes a first client and a first local proxy server. A socket (also known as a socket) can be created through the first client, and a communication connection can be established with the socket of the first local proxy server through the created socket. When establishing the communication connection, the communication address of the first local proxy server can be set to the local loopback address of the first device.
[0044] Among them, the socket can be regarded as an endpoint for communication between the first client and the first local proxy server, forming a channel for network communication. The local loopback address can be a special Internet Protocol (IP) address in a computer network, which allows the electronic device to send network data packets to itself through its own network interface without leaving the device.
[0045] S120. Transmit the data to be transmitted to the first local proxy server through the first client; wherein, the data to be transmitted includes the data that the first client in the first device needs to transmit to the second client in the second device through wireless transmission; the first device and the second device are connected through a Universal Serial Bus (USB).
[0046] The data to be transmitted can be the data that the first client in the first device needs to transmit to the second client in the second device. The second device can be an electronic device communicating with the first device, and the second client can be the client in the second device.
[0047] Universal Serial Bus (USB) can be a standard interface technology widely used between electronic devices. The first device and the second device involved in the present invention can communicate through the USB protocol.
[0048] The data to be transmitted can include the data that the first client needs to transmit to the second client through wireless transmission, specifically, it can be data related to upper-layer services, such as wireless transmission data or data involved in device mirroring. Among them, the wireless transmission method can be implemented based on Transmission Control Protocol / Internet Protocol (TCP / IP), which is not limited here. The upper-layer service can be a service or logic processing module at a relatively high level in the application layer. The upper-layer service does not directly face users, but processes complex business rules, data operations, and algorithm executions. There is a close connection between the client and the upper-layer service. For example, the client can send requests to the upper-layer service to request data or services, and the upper-layer service can also push data to the client, etc.
[0049] In the case where a network communication channel is established between the socket of the first client and the socket of the first local proxy server in S110, the data to be transmitted can be transmitted to the first local proxy server through the first client in this step.
[0050] S130. Transmit the data to be transmitted to the second local proxy server in the second device based on the USB protocol through the first local proxy server, so that the second client can obtain the data to be transmitted from the second local proxy server.
[0051] The second local proxy server can be a proxy server created locally in the second device.
[0052] In this step, when the first local proxy server obtains the data to be transmitted, synchronous USB mass writing can be performed to encapsulate the data to be transmitted into the data required to be transmitted by the USB protocol, and the data to be transmitted is transmitted from the first device to the second device through the USB protocol.
[0053] In the second device, the second local proxy server can obtain the data to be transmitted that is transmitted from the first device to the second device based on the USB protocol; the second client in the second device can establish a communication connection with the second local proxy server, and the second client can obtain the data to be transmitted from the second local proxy server; the second client then reports the obtained data to be transmitted to the upper-layer service corresponding to the second client for processing.
[0054] Through the above operations, when the first device and the second device communicate through the USB protocol, the upper-layer service can communicate through the TCP / IP protocol, thereby reducing the dependence of service developers on the USB protocol.
[0055] In the technical solution of the embodiment of the present invention, the first device includes a first client and a first local proxy server, the second device includes a second client and a second local proxy server, and the first device and the second device are connected through USB; the first client transmits the data to be transmitted that needs to be transmitted to the second client in a wireless transmission manner to the first local proxy server; the first local proxy server transmits the data to be transmitted to the second local proxy server based on the USB protocol, and the second client can obtain the data to be transmitted from the second local proxy server. This solution can simulate the USB protocol as a wireless transmission, that is, through the communication between the first client and the first local proxy server, the communication between the second client and the second local proxy server, and the communication between the first local proxy server and the second local proxy server based on the USB protocol, to simulate the wireless communication between the first client and the second client; service developers do not need to care whether the underlying is based on the USB protocol transmission or wireless transmission, and can be adapted through wireless transmission, increasing the portability and compatibility of the upper-layer service corresponding to the client; service developers do not need to understand the content of the USB protocol, reducing the development difficulty.
[0056] In one embodiment, transmitting the data to be transmitted to the first local proxy server through the first client includes:
[0057] Through the first client, call the first sending function adapted for wireless transmission, and transmit the data to be transmitted to the first local proxy server based on the socket handle of the first local proxy server.
[0058] The first sending function can be a function for transmitting data to be transmitted to the first local proxy server through the first client, and can be a function adapted for wireless transmission, such as the send function adapted for the TCP / IP protocol. The send function can be a function for sending data in socket communication.
[0059] The socket handle can be understood as an identifier used to uniquely identify an opened socket. The socket handle of the first local proxy server is the identifier for uniquely identifying the socket of the first local proxy server.
[0060] Among them, the first sending function can be expressed as: send(sockfd, buffer, actual_length, MSG_DONTWAIT). sockfd can be the socket handle of the first local proxy server; buffer indicates the buffer in the first client that stores the data to be transmitted; actual_length indicates the length of the data that actually needs to be sent in the above buffer, that is, the length of the data to be transmitted; MSG_DONTWAIT can be a non-blocking sending mode flag set during socket communication, and its function is to make the operation of the first sending function into a non-blocking sending mode, that is, if the sending operation cannot be completed immediately, an error-indicating message will be returned immediately.
[0061] Through the first client, by calling the first sending function, the data to be transmitted stored in the buffer of the first sending function can be transmitted to the first local proxy server indicated by sockfd through socket communication, the length of the transmitted data is the length indicated by actual_length, and the data transmission mode is the non-blocking sending mode.
[0062] In one embodiment, transmitting the data to be transmitted to the second local proxy server in the second device based on the USB protocol through the first local proxy server includes:
[0063] Through the first local proxy server, by calling the second sending function adapted for the USB protocol, the data to be transmitted is transmitted to the second local proxy server in the second device based on the USB handle of the first device and the USB handle of the second device.
[0064] The second sending function can be a function for transmitting data to be transmitted to a second local proxy server through a first local proxy server, and can be the libusb_bulk_transfer function adapted to the USB protocol. The libusb_bulk_transfer function can be an application programming interface function provided by the libusb library for handling bulk data transfer on a USB device. Libusb is a cross-platform library that allows developers to write application programs that can access USB devices.
[0065] A USB handle can be understood as an identifier used to uniquely identify an opened USB device. The USB handle of the first device is the identifier used to uniquely identify the first device as a USB device. The USB handle of the second device is the identifier used to uniquely identify the second device as a USB device.
[0066] Among them, the second sending function can be expressed as: libusb_bulk_transfer(dev_handle, endpoint, buffer, length, &actual_length, 0). dev_handle can be the USB handle of the first device, indicating the USB device being operated on; endpoint can be the USB handle of the second device, indicating the endpoint where data is sent; buffer indicates the buffer in the first local proxy server that stores the data to be transmitted. When the first local proxy server obtains the data to be transmitted, it can store it in its own buffer; length indicates the maximum length of data transfer; &actual_length indicates the length of the data that actually needs to be sent in the above buffer, that is, the length of the data to be transmitted.
[0067] Through the first local proxy server, by calling the second sending function, the data to be transmitted stored in the buffer of the second sending function can be transmitted to the second device indicated by endpoint through the first device indicated by dev_handle based on USB protocol communication, and the length of the transmitted data is the length indicated by &actual_length. Correspondingly, in the second device, the second local proxy server can obtain the data to be transmitted from the first device to the second device based on the USB protocol in a similar manner.
[0068] Embodiment 2
[0069] Figure 2It is a flowchart of a data transmission method provided by Embodiment 2 of the present invention. This embodiment is applicable to the situation where a second device receives data to be transmitted sent by a first device. This method can be executed by a data transmission device, which can be implemented in the form of software and / or hardware and integrated in an electronic device serving as the second device. Further, the electronic device includes, but is not limited to, a computer, a laptop computer, etc.
[0070] It should be noted that the embodiments of the present invention are described from the perspective of the data receiver in Embodiment 1 above. Contents not described in detail in this embodiment can be referred to in Embodiment 1 above.
[0071] As Figure 2 shown, the method includes:
[0072] S210. Establish a communication connection with a second local proxy server in the second device through a second client in the second device.
[0073] The second client can be a client in the second device. The second local proxy server can be a proxy server created locally in the second device.
[0074] In this step, the second device includes a second client and a second local proxy server. A socket (also known as a socket) can be created through the second client, and a communication connection can be established with the socket of the second local proxy server through the created socket. When establishing the communication connection, the communication address of the second local proxy server can be set as the local loopback address of the second device.
[0075] S220. Obtain the data to be transmitted transmitted by a first local proxy server in the first device based on the Universal Serial Bus (USB) protocol through the second local proxy server; wherein, the data to be transmitted includes data that a first client in the first device needs to transmit to the second client in a wireless transmission manner; the first device and the second device are connected through USB.
[0076] The data to be transmitted can be data that a first client in the first device needs to transmit to a second client in the second device. The first device can be an electronic device communicating with the second device. The first client can be a client in the first device. The first local proxy server can be a proxy server created locally in the first device.
[0077] The data to be transmitted may include data that the first client needs to transmit to the second client in a wireless transmission manner. Specifically, it may be data related to upper-layer services, such as wireless transmission data or data involved in device mirroring. Among them, the wireless transmission manner may be implemented based on the Transmission Control Protocol / Internet Protocol (TCP / IP), which is not limited here.
[0078] Universal Serial Bus (USB) can be a standard interface technology widely used between electronic devices. The first device and the second device involved in the present invention can communicate through the USB protocol.
[0079] In the case where the first local proxy server encapsulates the data to be transmitted into the data to be transmitted by the USB protocol and transmits the data to be transmitted from the first device to the second device through the USB protocol, the operations in this step can be executed. In this step, through the second local proxy server, USB mass storage reading can be performed to read the data to be transmitted that the first local proxy server transmits from the first device to the second device through the USB protocol.
[0080] S230. Obtain the data to be transmitted from the second local proxy server through the second client.
[0081] In the case of establishing a network communication channel between the socket of the second client and the socket of the second local proxy server in S210, and obtaining the data to be transmitted transmitted by the first local proxy server in the first device through the second local proxy server in S220, in this step, the data to be transmitted can be read from the second local proxy server through the second client. The second client can also report the read data to be transmitted to the upper-layer service corresponding to the second client for processing.
[0082] Through the above operations, in the case where the first device and the second device communicate through the USB protocol, the upper-layer service can communicate through the TCP / IP protocol, thereby reducing the dependence of service developers on the USB protocol.
[0083] In the technical solution of the embodiment of the present invention, a first client and a first local proxy server are included in a first device, a second client and a second local proxy server are included in a second device, and the first device and the second device are connected through USB; the second local proxy server obtains the data to be transmitted transmitted by the first local proxy server based on the USB protocol, and the second client can obtain the data to be transmitted from the second local proxy server. The data to be transmitted includes the data that the first client needs to transmit to the second client in a wireless transmission manner. This solution can simulate the USB protocol as a wireless transmission, that is, through the communication between the first client and the first local proxy server, the communication between the second client and the second local proxy server, and the communication between the first local proxy server and the second local proxy server based on the USB protocol, to simulate the wireless communication between the first client and the second client; business developers do not need to care whether the underlying is based on USB protocol transmission or wireless transmission, and can be adapted through wireless transmission, increasing the portability and compatibility of the upper-layer services corresponding to the client; business developers do not need to understand the content of the USB protocol, reducing the development difficulty.
[0084] In one embodiment, obtaining, by the second local proxy server, the data to be transmitted transmitted by the first local proxy server in the first device based on the Universal Serial Bus (USB) protocol includes:
[0085] By the second local proxy server, calling a first receiving function adapted to the USB protocol, and obtaining the data to be transmitted transmitted by the first local proxy server in the first device based on the USB handle of the first device and the USB handle of the second device.
[0086] The first receiving function can be a function for receiving the data to be transmitted transmitted by the first local proxy server through the second local proxy server, and can be the libusb_bulk_transfer function adapted to the USB protocol.
[0087] Among them, the first receiving function can be expressed as: libusb_bulk_transfer(dev_handle, endpoint, buffer, length, &actual_length, 0). dev_handle can be the USB handle of the second device, indicating the USB device being operated; endpoint can be the USB handle of the first device, indicating the endpoint for data reading (i.e., receiving); buffer indicates the buffer in the second local proxy server for storing the read data. When the second local proxy server obtains the data to be transmitted, it can store the obtained data to be transmitted in this buffer; length indicates the maximum length of data reception; &actual_length indicates the length of the actually received data in the above buffer, that is, the length of the data to be transmitted.
[0088] Through the second local proxy server, by calling the first receiving function, communication can be based on the USB protocol. The data to be transmitted sent by the first device can be read from the first device indicated by endpoint through the second device indicated by dev_handle, and the read data can be stored in the buffer indicated by buffer of the first receiving function. The length of the read data is the length indicated by &actual_length.
[0089] In one embodiment, obtaining the data to be transmitted from the second local proxy server through the second client includes:
[0090] Through the second client, by calling the second receiving function adapted for wireless transmission, the data to be transmitted is obtained from the second local proxy server based on the socket handle of the second local proxy server.
[0091] The second receiving function can be a function for reading the data to be transmitted from the second local proxy server through the second client and can be a function adapted for wireless transmission, such as the recv function adapted for the TCP / IP protocol. The recv function can be a function for receiving data in socket communication.
[0092] Among them, the second receiving function can be expressed as: recv(sockfd, buffer, len, 0). sockfd can be the socket handle of the second local proxy server; buffer indicates the buffer in the second client for storing the read data. When the second client obtains the data to be transmitted, it can store the obtained data to be transmitted in this buffer; len indicates the maximum length of data reception.
[0093] Through the second client, the second receiving function is called, and the data to be transmitted can be read from the second local proxy server indicated by sockfd through socket communication, and the read data to be transmitted is stored in the buffer of the second receiving function.
[0094] It should be noted that the length of the data to be transmitted read by calling the second receiving function should be the same as the length of the data actually received by calling the first receiving function, that is, the same as &actual_length in the first receiving function.
[0095] Embodiment III
[0096] Figure 3 It is a schematic structural diagram of a data transmission device provided according to Embodiment III of the present invention. This embodiment is applicable to the situation where a first device sends data to be transmitted to a second device. As Figure 3 shown, the specific structure of the device includes:
[0097] A first processing module 31, configured to establish a communication connection with a first local proxy server in the first device through a first client in the first device;
[0098] A second processing module 32, configured to transmit the data to be transmitted to the first local proxy server through the first client; wherein, the data to be transmitted includes data that the first client needs to transmit to a second client in the second device by wireless transmission; the first device and the second device are connected through a Universal Serial Bus (USB);
[0099] A third processing module 33, configured to transmit the data to be transmitted to a second local proxy server in the second device based on the USB protocol through the first local proxy server, so that the second client can obtain the data to be transmitted from the second local proxy server.
[0100] The data transmission device provided in this embodiment establishes a communication connection between the first client in the first device and the first local proxy server in the first device through the first processing module; transmits the data to be transmitted to the first local proxy server through the second processing module via the first client; wherein, the data to be transmitted includes the data that the first client needs to transmit to the second client in the second device by wireless transmission; the first device and the second device are connected by a Universal Serial Bus (USB); transmits the data to be transmitted to the second local proxy server in the second device based on the USB protocol through the third processing module via the first local proxy server, so that the second client can obtain the data to be transmitted from the second local proxy server. This solution can simulate the USB protocol as wireless transmission, that is, through the communication between the first client and the first local proxy server, the communication between the second client and the second local proxy server, and the communication between the first local proxy server and the second local proxy server based on the USB protocol, to simulate the wireless communication between the first client and the second client; business developers do not need to care whether the underlying is based on USB protocol transmission or wireless transmission, and can be adapted through wireless transmission, increasing the portability and compatibility of the upper-layer services corresponding to the client; business developers do not need to understand the content of the USB protocol, reducing the development difficulty.
[0101] Further, the second processing module 32 is specifically configured to:
[0102] Call the first sending function adapted for wireless transmission through the first client, and transmit the data to be transmitted to the first local proxy server based on the socket handle of the first local proxy server.
[0103] Further, the third processing module 33 is specifically configured to:
[0104] Call the second sending function adapted for the USB protocol through the first local proxy server, and transmit the data to be transmitted to the second local proxy server in the second device based on the USB handle of the first device and the USB handle of the second device.
[0105] The data transmission device provided in the embodiment of the present invention can execute the data transmission method provided in the first embodiment of the present invention, and has the corresponding functional modules and beneficial effects for executing the method.
[0106] Embodiment 4
[0107] Figure 4 It is a schematic structural diagram of a data transmission device provided according to Embodiment 4 of the present invention. This embodiment is applicable to the situation where the second device receives the data to be transmitted sent by the first device. As Figure 4As shown, the specific structure of the device includes:
[0108] A fourth processing module 41, configured to establish a communication connection with a second local proxy server in the second device through a second client in the second device;
[0109] A fifth processing module 42, configured to obtain data to be transmitted transmitted by a first local proxy server in a first device based on a Universal Serial Bus (USB) protocol through the second local proxy server; wherein, the data to be transmitted includes data that a first client in the first device needs to transmit to the second client in a wireless transmission manner; the first device and the second device are connected through USB;
[0110] A sixth processing module 43, configured to obtain the data to be transmitted from the second local proxy server through the second client.
[0111] In the data transmission device provided in this embodiment, the fourth processing module establishes a communication connection with a second local proxy server in the second device through a second client in the second device; the fifth processing module obtains data to be transmitted transmitted by a first local proxy server in a first device based on a Universal Serial Bus (USB) protocol through the second local proxy server; wherein, the data to be transmitted includes data that a first client in the first device needs to transmit to the second client in a wireless transmission manner; the first device and the second device are connected through USB; the sixth processing module obtains the data to be transmitted from the second local proxy server through the second client. This solution can simulate the USB protocol as a wireless transmission, that is, through the communication between the first client and the first local proxy server, the communication between the second client and the second local proxy server, and the communication between the first local proxy server and the second local proxy server based on the USB protocol, to simulate the wireless communication between the first client and the second client; business developers do not need to care whether it is based on USB protocol transmission or wireless transmission at the bottom layer, and can be adapted through wireless transmission, increasing the portability and compatibility of the upper-layer services corresponding to the client; business developers do not need to understand the content of the USB protocol, reducing the development difficulty.
[0112] Further, the fifth processing module 42 is specifically configured to:
[0113] Call a first reception function adapted to the USB protocol through the second local proxy server, and obtain the data to be transmitted transmitted by the first local proxy server in the first device based on the USB handle of the first device and the USB handle of the second device.
[0114] Further, the sixth processing module 43 is specifically configured to:
[0115] Through the second client, call the second receiving function adapted for wireless transmission, and obtain the data to be transmitted from the second local proxy server based on the socket handle of the second local proxy server.
[0116] The data transmission device provided by the embodiment of the present invention can execute the data transmission method provided by the second embodiment of the present invention, and has corresponding function modules and beneficial effects for executing the method.
[0117] Embodiment Five
[0118] The embodiment of the present invention provides a data transmission system, which includes a first device and a second device; wherein, the first device is used to implement the data transmission method provided in Embodiment One; the second device is used to implement the data transmission method provided in Embodiment Two.
[0119] Figure 5 is a schematic structural diagram of a data transmission system provided according to Embodiment Five of the present invention, as Figure 5 shown, the system includes a first device 51 and a second device 52, and the first device 51 and the second device 52 communicate through a USB protocol. The first device 51 includes a first client and a first local proxy server. The second device 52 includes a second client and a second local proxy server.
[0120] In the first device 51:
[0121] The first client is used to establish a communication connection with the first local proxy server in the first device;
[0122] The first client is used to call the first sending function adapted for wireless transmission, and transmit the data to be transmitted to the first local proxy server based on the socket handle of the first local proxy server;
[0123] The first local proxy server is used to call the second sending function adapted for the USB protocol, and transmit the data to be transmitted to the second local proxy server in the second device based on the USB handle of the first device and the USB handle of the second device.
[0124] In the second device 52:
[0125] The second client is used to establish a communication connection with the second local proxy server in the second device;
[0126] The second local proxy server is used to call the first receiving function adapted for the USB protocol, and obtain the data to be transmitted transmitted by the first local proxy server in the first device based on the USB handle of the first device and the USB handle of the second device;
[0127] A second client, configured to call a second receiving function adapted for wireless transmission, and obtain the data to be transmitted from the second local proxy server based on the socket handle of the second local proxy server.
[0128] The system can simulate the USB protocol as wireless transmission, that is, through the communication between the first client and the first local proxy server, the communication between the second client and the second local proxy server, and the communication between the first local proxy server and the second local proxy server based on the USB protocol, to simulate the wireless communication between the first client and the second client; business developers do not need to care whether the underlying is based on USB protocol transmission or wireless transmission, and can be adapted through wireless transmission, increasing the portability and compatibility of the upper-layer services corresponding to the clients; business developers do not need to understand the content of the USB protocol, reducing the development difficulty.
[0129] Embodiment Six
[0130] Figure 6 It is a schematic structural diagram of an electronic device implementing the embodiments of the present invention. The electronic device is intended to represent various forms of digital computers, such as desktop computers, workbenches, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, smart phones, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0131] As Figure 6 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.
[0132] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disc, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0133] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the data transmission method.
[0134] In some embodiments, the data transmission method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the data transmission method described above can be executed. Alternatively, in other embodiments, the processor 11 can be configured to execute the data transmission method by any other suitable means (e.g., by means of firmware).
[0135] The various embodiments of the systems and technologies described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs, which can be executed and / or interpreted on a programmable system including at least one programmable processor, the programmable processor can be a special or general programmable processor, can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0136] A computer program for implementing the method of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, a special purpose computer, or other programmable data processing device, such that when the computer programs are executed by the processor, the functions / operations specified in the flowchart and / or block diagram are implemented. The computer programs can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0137] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0138] In order to provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which the user can provide input to the electronic device. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0139] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected with each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), blockchain network, and the Internet.
[0140] A computing system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The client-server relationship is created by computer programs that run on the respective computers and have a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, and solves the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.
[0141] It should be understood that various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps recited in the present invention can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved, and this is not limited herein.
[0142] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
Claims
1. A data transmission method, characterized in that: Applied to a first device, the method includes: Establishing a communication connection with a first local proxy server in the first device through a first client in the first device; The data to be transmitted is transmitted to the first local proxy server through the first client; wherein the data to be transmitted includes data that the first client needs to transmit to the second client in the second device through wireless transmission; the first device and the second device are connected through a universal serial bus USB; The data to be transmitted is transmitted to a second local proxy server in the second device through the first local proxy server based on the USB protocol, so that the second client obtains the data to be transmitted from the second local proxy server.
2. The method according to claim 1, characterized in that Transmitting the data to be transmitted to the first local proxy server through the first client includes: The first sending function of the wireless transmission adapter is called through the first client, and the data to be transmitted is transmitted to the first local proxy server based on the socket handle of the first local proxy server.
3. The method according to claim 1, characterized in that The method of transmitting the data to be transmitted to a second local proxy server in the second device based on the USB protocol through the first local proxy server includes: The second sending function of the USB protocol adapter is called through the first local proxy server, and the data to be transmitted is transmitted to the second local proxy server in the second device based on the USB handle of the first device and the USB handle of the second device.
4. A data transmission method, characterized in that: Applied to the second device, the method includes: Establishing a communication connection with a second local proxy server in the second device through a second client in the second device; The second local proxy server obtains data to be transmitted transmitted by the first local proxy server in the first device based on the universal serial bus (USB) protocol; wherein the data to be transmitted includes data that the first client in the first device needs to transmit to the second client by wireless transmission; the first device and the second device are connected by USB; The data to be transmitted is obtained from the second local proxy server through the second client.
5. The method according to claim 4, characterized in that The method of obtaining, by the second local proxy server, data to be transmitted transmitted by the first local proxy server in the first device based on a universal serial bus (USB) protocol includes: The first receiving function of the USB protocol adapter is called through the second local proxy server, and the data to be transmitted transmitted by the first local proxy server in the first device is obtained based on the USB handle of the first device and the USB handle of the second device.
6. The method according to claim 4, characterized in that Obtaining the data to be transmitted from the second local proxy server through the second client includes: The second receiving function of the wireless transmission adapter is called through the second client, and the data to be transmitted is obtained from the second local proxy server based on the socket handle of the second local proxy server.
7. A data transmission device, characterized in that: Configured in a first device, the apparatus comprises: A first processing module, configured to establish a communication connection with a first local proxy server in the first device through a first client in the first device; a second processing module, configured to transmit the data to be transmitted to the first local proxy server through the first client; wherein the data to be transmitted includes data that the first client needs to transmit to the second client in the second device through wireless transmission; the first device and the second device are connected through a universal serial bus USB; The third processing module is used to transmit the data to be transmitted to a second local proxy server in the second device through the first local proxy server based on the USB protocol, so that the second client obtains the data to be transmitted from the second local proxy server.
8. A data transmission device, characterized in that: Configured in the second device, the apparatus comprises: a fourth processing module, configured to establish a communication connection with a second local proxy server in the second device through a second client in the second device; a fifth processing module, configured to obtain, through the second local proxy server, data to be transmitted transmitted by the first local proxy server in the first device based on a universal serial bus (USB) protocol; wherein the data to be transmitted includes data that the first client in the first device needs to transmit to the second client by wireless transmission; the first device and the second device are connected by USB; The sixth processing module is used to obtain the data to be transmitted from the second local proxy server through the second client.
9. A data transmission system, characterized in that: include: A first device and a second device; wherein the first device is used to execute the method as claimed in any one of claims 1-3; and the second device is used to execute the method as claimed in any one of claims 4-6.
10. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method according to any one of claims 1 to 3, or execute the method according to any one of claims 4 to 6.