Method for supporting socket application in web browser by using WebSocket tunnel
By using WebSocket tunnels and virtual network devices in web browsers, the problem of not being able to support full socket operations in the browser in the prior art is solved, and the function of supporting full socket operations without modifying the original code is realized, which improves usage efficiency and freedom.
Patent Information
- Application Number
- CN202311311262.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-10
- Publication Date
- 2025-04-11
AI Technical Summary
The prior art cannot support complete socket operations in web browsers, especially UDP and multiplexing mechanisms, and needs to modify C/C++ code to implement socket calls, and additional modifications to peer programs are required when using WASM programs.
By using WebSocket tunnels and virtual network devices (such as TUN/TAP devices), the function of using sockets in web browsers is realized without modifying the original C/C++ code. The specific method includes porting a part of the socket application into a WASM program, encapsulating and processing payloads using WebSocket, and transmitting data through a virtual network device.
It implements support for complete socket operations in web browsers, including TCP, UDP, multicast, etc., without modifying the original C/C++ code, breaking through the limitations of the browser sandbox mechanism and improving the freedom and efficiency of socket use.
Smart Images

Figure CN119814748A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to a method for supporting socket applications in a web browser using a WebSocket tunnel, and more particularly to a method for running a WASM program in a web browser using a WebSocket tunnel to support native (full-featured) sockets. Background Art
[0002] In recent years, with the development of front-end technology, the explosive growth of business needs has led to increasingly complex development logic, and the corresponding amount of code has also continued to increase, while the original JavaScript can no longer meet business requirements. In order to solve these problems, a universal bytecode WASM (WebAssembly) technology that can run on the browser side has emerged. This language-neutral technology enables multiple languages to be used to develop web applications, including C / C++. In embedded development, C / C++ is often used as the development language. Compared with typical web programs, embedded development usually requires access to external devices, and serial port access already has WebSerial technology; however, if the embedded program wants to access the socket, due to the sandbox mechanism of the web browser, it cannot perform transmission such as TCP and UDP. Although some existing tools provide some methods to access the socket, they only support TCP but not UDP, and are not stable. In addition, the existing tools do not support multiplexing mechanisms such as select and polling, which requires the server-side program of the socket to make architectural adjustments and a lot of code changes. Summary of the invention
[0003] Technical issues
[0004] In the prior art, some function calls of the socket in the Web browser cannot be supported, and the C / C++ source code needs to be modified to implement the call. In addition, when using the WASM program, additional modifications need to be made to the peer program for communication.
[0005] Technical Solution
[0006] The present invention proposes a solution based on a WebSocket tunnel and a virtual network device such as a TUN / TAP device to solve the above problems, and can better achieve the purpose of using sockets in a web browser without modifying the original program developed in C / C++ language.
[0007] According to one aspect of the present disclosure, there is provided a method for supporting socket applications in a web browser using WebSocket, which is implemented by a computing device, and includes: the computing device transplants a portion of a first application into a WASM program; the computing device encapsulates a payload payload using WebSocket at the portion of the first application and sends it to a second application; the computing device processes the received encapsulated payload using WebSocket through the second application to obtain the payload; and the computing device sends the payload to a virtual network device through the second application for data transmission.
[0008] Optionally, the method further includes: wherein the first application includes a socket application module that generates a payload, a protocol stack module that includes the portion of the first application, and a WebSocket data proxy module, and the second application includes a local application that is not a web browser.
[0009] Optionally, the method further includes: wherein the encapsulation includes adding a WebSocket data header to the payload through a WebSocket data proxy module, and placing it in a WebSocket tunnel for transmission.
[0010] Optionally, the method further includes: wherein the processing includes removing a WebSocket data header from the encapsulated payload.
[0011] Optionally, the method further includes: wherein, transplanting a portion of the first application into the WASM program to implement a socket-related function interface.
[0012] Optionally, the method further includes: wherein the protocol stack module includes a TCP / IP protocol stack and a LwIP (Lightweight IP) protocol stack.
[0013] Optionally, the method further includes: wherein the virtual network device includes a TAP device, and the transceiver interface of the portion in the first application includes a layer 2 transceiver interface.
[0014] Optionally, the method further includes: if the first application only requires network layer 3 and above functions, the virtual network device includes a TUN device, and the transceiver interface includes a three-layer transceiver interface.
[0015] Optionally, the method further includes: wherein, when the WASM program wants to access a protocol below layer 7, the web browser of the computing device needs to access an external network.
[0016] According to one aspect of the present disclosure, a method for supporting socket applications in a web browser using WebSocket, implemented by a computing device, is provided, comprising: the computing device transplanting a portion of a first application into a WASM program; the computing device receiving a payload from a virtual network device through a second application; the computing device encapsulating the payload using WebSocket at the second application and sending the payload to the portion in the first application; and the computing device receiving the encapsulated payload through the portion in the first application, and processing the received encapsulated payload using WebSocket to obtain the payload.
[0017] Optionally, the method further includes: wherein the first application includes a socket application module that generates a payload, a protocol stack module that includes the portion of the first application, and a WebSocket data proxy module, and the second application includes a local application that is not a web browser.
[0018] Optionally, the method further includes: wherein the encapsulation includes adding a WebSocket data header to the payload through a WebSocket data proxy module, and placing it in a WebSocket tunnel for transmission.
[0019] Optionally, the method further includes: wherein the processing includes removing a WebSocket data header from the encapsulated payload.
[0020] Optionally, the method further includes: wherein, transplanting a portion of the first application into the WASM program to implement a socket-related function interface.
[0021] Optionally, the method further includes: wherein the protocol stack module includes a TCP / IP protocol stack and a LwIP (Lightweight IP) protocol stack.
[0022] Optionally, the method further includes: wherein the virtual network device includes a TAP device, and the transceiver interface of the portion in the first application includes a layer 2 transceiver interface.
[0023] Optionally, the method further includes: if the first application only requires network layer 3 and above functions, the virtual network device includes a TUN device, and the transceiver interface includes a three-layer transceiver interface.
[0024] Optionally, the method further includes: wherein, when the WASM program wants to access a protocol below layer 7, the web browser of the computing device needs to access an external network.
[0025] According to one aspect of the present disclosure, a computing device for implementing a method for supporting a socket application in a web browser using a WebSocket tunnel is provided. The computing device includes a processor for implementing any of the aforementioned methods.
[0026] According to one aspect of the present disclosure, a non-transitory computer-readable memory is provided, on which instructions are stored. When the instructions are executed, a processor is enabled to implement any of the aforementioned methods.
[0027] Beneficial Effects
[0028] The present invention utilizes WebSocket tunnel to run WASM program in web browser to support all socket operations, including but not limited to TCP, UDP, multicast, socket options, etc., and the present invention does not need to modify the original C / C++ code to support the code running in the browser. With user authorization, it is possible to break through the restrictions on the use of sockets by the sandbox mechanism of the web browser and obtain greater freedom in the use of sockets. The commercial applications of this patent include virtual device display systems and digital twin systems. In addition, the network security of programs is now very important. If it is necessary to encrypt communications, the encryption library can also be integrated to implement TLS or DTS functions. The present invention provides a convenient method to support native sockets, which reduces the amount of code modification, achieves the purpose of reducing complexity, and thus improves efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The aspects, features and advantages of the present disclosure will become clearer and easier to understand through the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0030] Figure 1 A flowchart of using a WebSocket tunnel to support data transmission of a socket application in a web browser according to an embodiment of the present disclosure is shown;
[0031] Figure 2 A flowchart showing how to support data reception of a socket application in a web browser using a WebSocket tunnel according to an embodiment of the present disclosure is shown;
[0032] Figure 3 A schematic diagram showing an implementation of a user area protocol stack according to an embodiment of the present disclosure;
[0033] Figure 4 A schematic diagram of a device for implementing the use of a WebSocket tunnel to run a WASM program in a web browser to support a native socket method according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0034] Before proceeding to the following detailed description, it may be advantageous to set forth the definitions of certain words and phrases used throughout this patent document. The terms "coupling", "connection" and their derivatives refer to any direct or indirect communication or connection between two or more elements, regardless of whether those elements are in physical contact with each other. The terms "transmission", "reception" and "communication" and their derivatives cover direct and indirect communication. The terms "include" and "comprise" and their derivatives refer to including but not limited to. The term "or" is inclusive, meaning and / or. The phrases "associated with...", "corresponding to..." and their derivatives refer to including, including within, interconnecting, including, including within, connecting or connecting with, coupling or coupling with, communicating with, cooperating, interweaving, parallel, close to, binding or binding with, having, having attributes, having a relationship or having a relationship with, etc. The term "controller" refers to any device, system or part thereof that controls at least one operation. Such a controller can be implemented with hardware, or a combination of hardware and software and / or firmware. The functions associated with any particular controller can be centralized or distributed, whether local or remote. The phrase "at least one of", when used with a list of items, means that different combinations of one or more of the listed items may be used, and only one of the items in the list may be required. For example, "at least one of A, B, C" includes any of the following combinations: A, B, C, A and B, A and C, B and C, A and B and C.
[0035] Definitions for other specific words and phrases are provided throughout this patent document. Those of ordinary skill in the art should understand that in many, if not most instances, such definitions apply to prior and future uses of such defined words and phrases.
[0036] In this patent document, the application combination of units and the division level of subunits are only for illustration, and the application combination of units and the division level of subunits can be in different ways without departing from the scope of the present disclosure. The embodiments of the present disclosure can be implemented in different forms and should not be interpreted as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to make the present disclosure thorough and complete, and to fully convey exemplary implementation methods to those skilled in the art. The embodiments of the present disclosure can be combined to form additional embodiments.
[0037] The present disclosure will be described in detail below with reference to exemplary embodiments of the present disclosure. However, the present disclosure is not limited to the embodiments described herein, and it can be implemented in many different forms. The described embodiments are only used to make the present disclosure thorough and complete, and to fully convey the concept of the present disclosure to those skilled in the art. The features of the various embodiments described can be combined or replaced with each other, unless explicitly excluded or should be excluded according to the context.
[0038] Figure 1 A flow chart of using a WebSocket tunnel to support data transmission of a socket application in a web browser according to an embodiment of the present disclosure is shown.
[0039] like Figure 1As shown, the computing system 100 in the computing device 10 according to an embodiment of the present disclosure may include a web browser 101 and a local application (not a web browser, which can access all local resources) 102. The web browser 101 may include a socket application module, a protocol stack module and a WebSocket data proxy module for generating a payload. Accordingly, the web browser 101 may include a protocol stack, a socket application and a WebSocket data proxy that can be used in the user area, wherein the protocol stack that can be used in the user area includes a TCP / IP protocol stack, and optionally, the protocol stack that can be used in the user area also includes an LwIP (Light weight IP) protocol stack, and the protocol stack that can be used in the user area is completely transplanted into the WASM program. In this case, it can be ensured that the socket-related function interface is completely implemented; wherein, the socket application and the protocol stack in the user area can communicate through the socket programming interface; wherein, the bottom layer of the protocol stack needs to send data and uses WebSocket to encapsulate the payload through the WebSocket data proxy, and then the encapsulated data (e.g., payload) can be put into the WebSocket tunnel for transmission, and optionally, the encapsulation can be to add a WebSocket data header to the payload through the WebSocket data proxy module, and then put it into the WebSocket tunnel for transmission. The local application 102 can receive the encapsulated data from the WebSocket tunnel through the WebSocket data proxy. The local application 102 can use WebSocket to process the received encapsulated payload, and can remove the WebSocket data header to obtain the payload. Then, the local application 102 can send the payload to the virtual network device. Optionally, the virtual network device may include a TAP device. For example, based on the needs of the upper-layer application (including the socket application), if the upper-layer application requires a network layer 2 function (e.g., address resolution protocol (ARP)), a TAP device may be created, and the transceiver interface of the protocol stack may be a layer 2 transceiver interface. Optionally, as an advanced function, the virtual network device may also include a TUN device. If the upper-layer application only requires network layer 3 and above functions, a TUN device may be created, and the transceiver interface of the protocol stack may be a layer 3 transceiver interface. Optionally, when the WASM program wants to access the protocol below layer 7, the web simulator of the embedded device needs to access the external network. According to an embodiment of the present disclosure, the web browser 101 in the computing system 100 needs to access the external network. After the virtual network device receives the payload, it can communicate with other programs according to different communication requirements, including but not limited to Ethernet interfaces, WIFI interfaces, etc.
[0040] Specifically, according to an embodiment of the present disclosure, in step S101, the computing device 10 can transplant the protocol stack of the user area in the socket application to the WASM program. In step S102, the computing device 10 adds a WebSocket data header to the payload from the socket application at the bottom of the protocol stack, and puts it into the WebSocket tunnel to send it to the local application 102. Specifically, encapsulation includes: during encapsulation, the WebSocket data header can be added to the user's payload in the data stream from the upper-layer socket application at the bottom of the protocol stack through the WebSocket data proxy, and then put it into the WebSocket tunnel for transmission. In step S103, the local application 102 receives the encapsulated payload and uses WebSocket to remove the WebSocket data header to obtain the payload. Specifically, the processing includes: the local application 102 receives the payload with the WebSocket data header from the WebSocket tunnel through the WebSocket data proxy, and removes the WebSocket data header from the payload with the WebSocket data header. In step S104, the local application 102 sends the payload with the WebSocket data header removed to the virtual network device. Among them, the virtual network device may include a TAP device. For example, based on the needs of the upper-layer application, if the upper-layer application requires network layer 2 functions, the local application 102 can create a TAP device and transmit the payload without the WebSocket data header to the TAP device. Optionally, if the upper-layer application only requires network layer 3 and above functions, the local application 102 can create a TUN device and transmit the payload without the WebSocket data header to the TUN device.
[0041] Optionally, when the WASM program needs to access the protocol below layer 7, the web simulator of the embedded device needs to access the external network. According to an embodiment of the present disclosure, when the WASM program needs to access the protocol below layer 7, the web browser 101 in the computing system 100 in the computing device 10 needs to access the external network. Optionally, based on communication requirements, the local application 102 can add, for example, an Ethernet header to the data packet (including the payload) sent from the virtual network device for subsequent data transmission with the external program.
[0042] According to an embodiment of the present disclosure, a process of using a WebSocket tunnel to run a WASM program in a web browser to support data reception of a native socket application is described below. Figure 1 The data transmission process is similar, except that the data transmission direction is opposite. Figure 2 shown.
[0043] Figure 2 A flow chart of using a WebSocket tunnel to support data reception of a socket application in a web browser according to an embodiment of the present disclosure is shown.
[0044] like Figure 2As shown, the computing system 200 in the computing device 10 according to the embodiment of the present disclosure may include a web browser 201 and a local application (non-web browser, which can access all local resources) 202. The web browser 201 may include a socket application module, a protocol stack module and a WebSocket data proxy module that generate a payload. Accordingly, the web browser 201 may include a protocol stack, a socket application and a WebSocket data proxy that can be used in the user area, wherein the protocol stack that can be used in the user area includes a TCP / IP protocol stack, and optionally, the protocol stack that can be used in the user area also includes an LwIP (Light weight IP) protocol stack, which can be used in the user area. The protocol stack that can be used in the user area is completely transplanted into the WASM program. In this case, it can be ensured that the socket-related function interface is fully implemented; wherein, the socket application and the protocol stack of the user area can communicate through the socket programming interface. The local application 202 may receive a payload from a virtual network device, wherein the virtual network device may include a TAP device, the corresponding upper layer application may require a network layer 2 function (e.g., address resolution protocol (ARP)), and the transceiver interface of the protocol stack may be a layer 2 transceiver interface. Optionally, based on the requirements of the upper layer application (including the socket application), as an advanced function, the virtual network device may also include a TUN device, and the corresponding upper layer application may only require network layer 3 and above functions, and the transceiver interface of the protocol stack may be a layer 3 transceiver interface. The payload may be encapsulated using WebSocket at the local application 202 and may be sent to the bottom layer of the protocol stack. The encapsulation may add a WebSocket data header to the payload through a WebSocket data proxy module, and then the encapsulated payload may be placed in a WebSocket tunnel for transmission. The bottom layer of the protocol stack may receive the encapsulated payload, and may use WebSocket to process the received encapsulated payload to obtain the payload. The bottom layer of the protocol stack may remove the WebSocket data header from the encapsulated payload to obtain the payload. Optionally, when the WASM program needs to access protocols below layer 7, the web simulator of the embedded device needs to access an external network. According to an embodiment of the present disclosure, the web browser 201 in the computing system 100 needs to access an external network. The virtual network device can generate a payload and send it to other programs. Optionally, according to different communication requirements, the virtual network device can communicate with other programs through, including but not limited to, Ethernet interfaces, WIFI interfaces, etc., and receive corresponding payloads.
[0045] Specifically, according to an embodiment of the present disclosure, in step S201, the computing device 10 can transplant the protocol stack of the user area in the socket application to the WASM program. In step S202, the computing device 10 can add a WebSocket data header to the payload from the virtual network device at the local application 202, and put it into the WebSocket tunnel to send it to the bottom layer of the protocol stack. Specifically, encapsulation includes: during encapsulation, the WebSocket data proxy can be used to add a WebSocket data header to the user's payload in the data stream from the virtual network device at the bottom layer of the protocol stack, and then put it into the WebSocket tunnel for transmission. Among them, the virtual network device can include a TAP device, the corresponding upper layer application may require a network layer 2 function (for example, address resolution protocol (ARP)), and the transceiver interface of the protocol stack can be a layer 2 transceiver interface; optionally, as an advanced function, the virtual network device can also include a TUN device, the corresponding upper layer application may only require network layer 3 and above functions, and the transceiver interface of the protocol stack can be a layer 3 transceiver interface. In step S203, the protocol stack bottom layer may receive the encapsulated payload and use WebSocket to remove the WebSocket data header to obtain the payload. Specifically, the processing includes: the protocol stack bottom layer receives the payload with the WebSocket data header from the WebSocket tunnel through the WebSocket data proxy, and removes the WebSocket data header from the payload with the WebSocket data header. In step S204, the protocol stack bottom layer may use the payload without the WebSocket data header for interaction with the socket application.
[0046] Optionally, when the WASM program needs to access the protocol below layer 7, the web simulator of the embedded device needs to access the external network. According to an embodiment of the present disclosure, when the WASM program needs to access the protocol below layer 7, the web browser 201 in the computing system 100 in the computing device 10 needs to access the external network. Optionally, based on communication requirements, the local application 202 can add, for example, an Ethernet header to the data packet (including the payload) sent from the virtual network device for subsequent data transmission with the external program.
[0047] Figure 3 A schematic diagram showing an implementation of a user area protocol stack according to an embodiment of the present disclosure.
[0048] like Figure 3As shown, according to an embodiment of the present disclosure, the browser 301 in the computing system 300 may include a socket application and an LwIP protocol stack that can be used in the user area. The LwIP protocol stack is an implementation of an open source lightweight TCP / IP protocol stack, which provides a standard socket interface (for example, including socket function calls send, recv, select, etc.) to the upper-layer socket application. Furthermore, the underlying interface of LwIP was originally intended to adapt to the transmission (TX) and reception (RX) of Ethernet L2. According to an embodiment of the present disclosure, it is replaced by using the WebSocket method to encapsulate the payload in the data stream and realize the transmission in the WebSocket tunnel through the WebSocket data proxy. When LwIP sends data, a WebSocket header is added to the payload. When LwIP receives data, the WebSocket header will be removed from the payload and transmitted back to the LwIP protocol stack.
[0049] Figure 4 A schematic diagram of a device for implementing a method for running a WASM program in a web browser using a WebSocket tunnel to support native socket applications according to an embodiment of the present disclosure is shown.
[0050] like Figure 4 As shown, the computing device 10 may include a processor 401 and a memory 402, and the processor 401 may be configured to control the software in the computing device 10 to implement the method described in the present disclosure. The memory 402 may be configured to store instructions so that the processor 401 can implement any method described in the present disclosure. The computing device 10 may be implemented in the form of hardware, software, or a combination of hardware and software so that it can perform any one or more steps in any method described in the present disclosure.
[0051] Those skilled in the art will appreciate that the various illustrative logic boxes, modules, circuits, and steps described in the present application can be implemented as hardware, software, or a combination of the two. To clearly illustrate this interchangeability of hardware and software, various illustrative components, boxes, modules, circuits, and steps are described generally in the form of their function sets above. Whether such function sets are implemented as hardware or software depends on specific applications and the design constraints imposed on the overall system. Technicians can implement the described function sets in different ways for each specific application, but such design decisions should not be interpreted as causing a departure from the scope of the present application.
[0052] The various illustrative logic blocks, modules, and circuits described herein may be implemented or executed with a general purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general purpose processor may be a microprocessor, but in an alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. The processor may also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in cooperation with a DSP core, or any other such configuration.
[0053] The method or algorithm described in the present application can be directly embodied in hardware, in a software module executed by a processor, or in a combination of the two. The software module can reside in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read and write information from / to the storage medium. In an alternative, a storage medium can be integrated into a processor. The processor and the storage medium can reside in an ASIC. The ASIC can reside in a user terminal. In an alternative, the processor and the storage medium can reside in a user terminal as discrete components.
[0054] In one or more exemplary designs, the functions may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software, the functions may be stored on or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include both computer storage media and communication media, the latter including any media that facilitates the transfer of a computer program from one place to another. Storage media may be any available media that can be accessed by a general or special purpose computer.
[0055] The embodiments of the present application are only for easy description and help to fully understand the present disclosure, and are not intended to limit the scope of the present disclosure. Therefore, it should be understood that, in addition to the embodiments disclosed herein, all modifications and changes or modified and changed forms of the technical conception derived from the present disclosure fall within the scope of the present disclosure.
Claims
1. A method implemented by a computing device to support a socket application in a web browser using WebSocket, comprising: The computing device transplants a portion of the first application into the WASM program; The computing device encapsulates the payload at the portion of the first application using WebSocket and sends the payload to the second application; The computing device processes the received encapsulated payload using WebSocket through the second application to obtain the payload; as well as The computing device sends the payload to the virtual network device through the second application for data transmission.
2. The method of claim 1, wherein: The first application includes a socket application module that generates a payload, a protocol stack module that includes the portion of the first application, and a WebSocket data proxy module, and The second application includes a native application that is not a web browser.
3. The method of claim 1, wherein: The encapsulation includes adding a WebSocket data header to the payload through a WebSocket data proxy module, and placing it in a WebSocket tunnel for transmission.
4. The method of claim 1, wherein: The processing includes removing the WebSocket data header from the encapsulated payload.
5. The method of claim 1, wherein: The step of transplanting a part of the first application into the WASM program is used to implement a function interface related to the socket.
6. The method of claim 1, wherein: The protocol stack module includes a TCP / IP protocol stack and an LwIP (Lightweight IP) protocol stack.
7. The method of claim 1, wherein: The virtual network device includes a TAP device, and the transceiver interface of the portion in the first application includes a layer 2 transceiver interface.
8. The method of claim 7, wherein: If the first application only requires network layer 3 and above functions, the virtual network device includes a TUN device, and the transceiver interface includes a three-layer transceiver interface.
9. The method of claim 1, wherein: When a WASM program wants to access protocols below layer 7, the web browser of the computing device needs to access the external network.
10. A method implemented by a computing device to support a socket application in a web browser using WebSocket, comprising: The computing device transplants a portion of the first application into the WASM program; Receiving, by the computing device through a second application, a payload from a virtual network device; The computing device encapsulates the payload at the second application using WebSocket and sends the payload to the portion in the first application; as well as The computing device receives the encapsulated payload through the portion of the first application, and processes the received encapsulated payload using WebSocket to obtain the payload.
11. The method of claim 10, wherein: The first application includes a socket application module that generates a payload, a protocol stack module that includes the portion of the first application, and a WebSocket data proxy module, and The second application includes a native application that is not a web browser.
12. The method of claim 10, wherein: The encapsulation includes adding a WebSocket data header to the payload through a WebSocket data proxy module, and placing it in a WebSocket tunnel for transmission.
13. The method of claim 10, wherein: The processing includes removing the WebSocket data header from the encapsulated payload.
14. The method of claim 10, wherein: The step of transplanting a part of the first application into the WASM program is used to implement a function interface related to the socket.
15. The method of claim 10, wherein: The protocol stack module includes a TCP / IP protocol stack and an LwIP (Lightweight IP) protocol stack.
16. The method of claim 10, wherein: The virtual network device includes a TAP device, and the transceiver interface of the portion in the first application includes a layer 2 transceiver interface.
17. The method of claim 16, wherein: If the first application only requires network layer 3 and above functions, the virtual network device includes a TUN device, and the transceiver interface includes a three-layer transceiver interface.
18. The method of claim 10, wherein: When a WASM program wants to access protocols below layer 7, the web browser of the computing device needs to access the external network.
19. A computing device for implementing a method for supporting a socket application in a web browser using a WebSocket tunnel, the computing device comprising a processor for implementing the method of any one of claims 1 to 18.
20. A non-transitory computer readable memory having instructions stored thereon, which when executed, cause a processor to implement the method of any one of the preceding claims 1-18.