Multi-terminal connection establishing method and device, storage medium and electronic device

文档序号:1449078 发布日期:2020-02-18 浏览:19次 中文

阅读说明:本技术 多终端的连接建立方法和装置、存储介质及电子装置 (Multi-terminal connection establishing method and device, storage medium and electronic device ) 是由 冯伟忠 于 2019-12-16 设计创作,主要内容包括:本发明公开了一种多终端的连接建立方法和装置、存储介质及电子装置。其中,该方法包括:在第一终端上获取第二终端的第二IP地址;在第一终端上向第二IP地址发送第一连接建立请求;在第一连接建立失败的情况下,在第一终端上获取第二终端向所述第一IP地址发送的第二连接建立请求;响应于第二连接建立请求,建立第一终端和所述第二终端之间的所述第二连接。本发明解决了手机端与PC端无法建立连接的技术问题。(The invention discloses a method and a device for establishing connection of multiple terminals, a storage medium and an electronic device. Wherein, the method comprises the following steps: acquiring a second IP address of a second terminal on the first terminal; sending a first connection establishment request to a second IP address on a first terminal; under the condition that the first connection is failed to be established, a second connection establishment request sent to the first IP address by a second terminal is obtained on the first terminal; and responding to a second connection establishment request, and establishing the second connection between the first terminal and the second terminal. The invention solves the technical problem that the connection between the mobile phone end and the PC end can not be established.)

1. A method for establishing connection of multiple terminals is characterized by comprising the following steps:

acquiring a second IP address of a second terminal on the first terminal;

sending a first connection establishment request to the second IP address on the first terminal, wherein the first connection establishment request carries the first IP address of the first terminal, and the first connection establishment request is used for requesting to establish a first connection between the first terminal and the second terminal;

under the condition that the first connection is failed to be established, acquiring a second connection establishment request sent by the second terminal to the first IP address on the first terminal, wherein the second connection establishment request is used for requesting to establish a second connection between the first terminal and the second terminal;

establishing the second connection between the first terminal and the second terminal in response to the second connection establishment request.

2. The method of claim 1, wherein after sending a first connection establishment request to the second IP address on the first terminal, the method further comprises:

and determining that the first connection establishment fails under the condition that the firewall on the second terminal rejects the first connection establishment request.

3. The method according to claim 1, wherein the obtaining, at the first terminal, the second connection establishment request sent by the second terminal to the first IP address comprises:

establishing a target monitoring task on the first terminal, wherein the target monitoring task is used for monitoring a connection establishment request sent to the first IP address;

and monitoring the second connection establishment request through the target monitoring task on the first terminal.

4. The method of claim 3,

the establishing of the target monitoring task on the first terminal includes: establishing a first monitoring task on the first terminal, wherein the target monitoring task comprises the first monitoring task, and the first monitoring task is used for monitoring a connection establishment request sent to a target port of the first IP address;

the monitoring the second connection establishment request through the target monitoring task on the first terminal includes: and monitoring the second connection establishment request sent by the second terminal to the target port of the first IP address through the first monitoring task on the first terminal.

5. The method according to claim 4, wherein said establishing the second connection between the first terminal and the second terminal in response to the second connection establishment request comprises:

and under the condition that the target port is a TCP port and the second connection establishment request is an RTMP connection establishment request, establishing RTMP connection between the first terminal and the second terminal.

6. The method according to any of claims 1 to 5, characterized in that after establishing the second connection between the first terminal and the second terminal in response to the second connection establishment request, the method further comprises:

and transmitting the picture information displayed on the screen of the first terminal to the second terminal through the second connection on the first terminal, wherein the picture information is used for displaying on the second terminal.

7. The method according to any of claims 1 to 5, wherein before acquiring, at the first terminal, the second connection establishment request sent by the second terminal to the first IP address, the method comprises:

under the condition that the first connection is failed to be established, acquiring the first IP address of the first terminal on the second terminal;

and sending the second connection establishment request to the first IP address on the second terminal.

8. The method of claim 6, wherein the obtaining the first IP address of the first terminal at the second terminal comprises:

and acquiring the first IP address of the first terminal sent by a background server on the second terminal, wherein the first IP address in the background server is uploaded to the background server by the first terminal.

9. A multi-terminal connection establishment apparatus, comprising:

the first acquisition module is used for acquiring a second IP address of a second terminal on the first terminal;

a sending module, configured to send a first connection establishment request to the second IP address on the first terminal, where the first connection establishment request carries a first IP address of the first terminal, and the first connection establishment request is used to request establishment of a first connection between the first terminal and the second terminal;

a second obtaining module, configured to obtain, on the first terminal, a second connection establishment request sent by the second terminal to the first IP address under the condition that the first connection establishment fails, where the second connection establishment request is used to request establishment of a second connection between the first terminal and the second terminal;

an establishing module, configured to establish the second connection between the first terminal and the second terminal in response to the second connection establishment request.

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

Technical Field

The invention relates to the field of computers, in particular to a method and a device for establishing connection of multiple terminals, a storage medium and an electronic device.

Background

The screen picture is captured through a client Application program (App for short) at the mobile phone end, and the screen picture is sent to a server at a Personal Computer (PC for short) end after being coded and compressed, and then is decoded and displayed, so that the picture of the mobile phone is displayed on the PC.

In the existing screen projection scheme, a monitoring server is established at a PC end, then connection is initiated at a mobile phone end, and data flow is routed from a mobile phone APP to a network and finally to the server of the PC. However, the PC side is generally provided with a firewall, and if the firewall on the PC side is not configured, the data packet will be intercepted by the network firewall on the PC side, so that the connection fails.

Aiming at the problem that in the related art, a firewall of a PC (personal computer) end intercepts a data packet, so that connection between a mobile phone end and the PC end cannot be established, an effective solution is not provided at present.

Disclosure of Invention

The embodiment of the invention provides a method and a device for establishing connection of multiple terminals, a storage medium and an electronic device, and at least solves the technical problem that the connection between a mobile phone end and a PC end cannot be established.

According to an aspect of the embodiments of the present invention, there is provided a method for establishing a connection between multiple terminals, including: acquiring a second IP address of a second terminal on the first terminal; sending a first connection establishment request to the second IP address on the first terminal, wherein the first connection establishment request carries the first IP address of the first terminal, and the first connection establishment request is used for requesting to establish a first connection between the first terminal and the second terminal; under the condition that the first connection is failed to be established, acquiring a second connection establishment request sent by the second terminal to the first IP address on the first terminal, wherein the second connection establishment request is used for requesting to establish a second connection between the first terminal and the second terminal; establishing the second connection between the first terminal and the second terminal in response to the second connection establishment request.

According to another aspect of the embodiments of the present invention, there is also provided a multi-terminal connection establishing apparatus, including: the first acquisition module is used for acquiring a second IP address of a second terminal on the first terminal; a sending module, configured to send a first connection establishment request to the second IP address on the first terminal, where the first connection establishment request carries a first IP address of the first terminal, and the first connection establishment request is used to request establishment of a first connection between the first terminal and the second terminal; a second obtaining module, configured to obtain, on the first terminal, a second connection establishment request sent by the second terminal to the first IP address under the condition that the first connection establishment fails, where the second connection establishment request is used to request establishment of a second connection between the first terminal and the second terminal; an establishing module, configured to establish the second connection between the first terminal and the second terminal in response to the second connection establishment request.

According to still another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium having a computer program stored therein, wherein the computer program is configured to execute the above-mentioned multi-terminal connection establishment method when running.

According to another aspect of the embodiments of the present invention, there is also provided an electronic apparatus, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the method for establishing a connection between multiple terminals through the computer program.

In the embodiment of the present invention, a first connection request is sent to an acquired IP address of a second terminal by a first terminal, and is used to request establishment of a first connection between the first terminal and the second terminal. And under the condition that the first connection is failed to be established, the second terminal sends a second connection establishment request to the first terminal, the second connection establishment request is used for requesting to establish a second connection between the first terminal and the second terminal, and the second connection is established between the first terminal and the second terminal. Therefore, the technical effect of establishing connection between the mobile phone end and the PC end is achieved, and the technical problem that the connection between the mobile phone end and the PC end cannot be established is solved.

Drawings

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

fig. 1 is a flowchart of a connection establishment method of a multi-terminal according to an embodiment of the present invention;

fig. 2 is a first schematic diagram of an alternative method for establishing a multi-terminal connection according to an alternative embodiment of the present invention;

fig. 3 is a second schematic diagram of an alternative multi-terminal connection establishment method according to an alternative embodiment of the present invention;

fig. 4 is a third schematic diagram of an alternative multi-terminal connection establishment method according to an alternative embodiment of the present invention;

fig. 5 is a fourth schematic diagram of an alternative multi-terminal connection establishment method according to an alternative embodiment of the present invention;

fig. 6 is a schematic diagram of an application environment of an alternative multi-terminal connection establishment method according to an embodiment of the present invention;

fig. 7 is a fifth schematic diagram of an alternative multi-terminal connection establishment method according to an alternative embodiment of the present invention;

fig. 8 is a sixth schematic diagram of an alternative multi-terminal connection establishment method according to an alternative embodiment of the present invention;

fig. 9 is a seventh schematic diagram of an alternative multi-terminal connection establishment method according to an alternative embodiment of the present invention;

fig. 10 is an eighth schematic diagram of an alternative multi-terminal connection establishment method according to an alternative embodiment of the present invention;

fig. 11 is a schematic diagram of an alternative multi-terminal connection setup apparatus according to an embodiment of the present invention;

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

Detailed Description

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

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

According to an aspect of the embodiments of the present invention, as an optional implementation manner, as shown in fig. 1, a method for establishing a multi-terminal connection is provided, where the method for establishing a multi-terminal connection includes the following steps:

step S102, a second IP address of a second terminal is obtained on a first terminal;

step S104, sending a first connection establishment request to the second IP address on the first terminal, wherein the first connection establishment request carries the first IP address of the first terminal, and the first connection establishment request is used for requesting to establish a first connection between the first terminal and the second terminal;

step S106, under the condition that the first connection is failed to be established, a second connection establishment request sent by the second terminal to the first IP address is obtained on the first terminal, wherein the second connection establishment request is used for requesting to establish a second connection between the first terminal and the second terminal;

step S108, in response to the second connection establishment request, establishing the second connection between the first terminal and the second terminal.

Optionally, the first terminal may be a mobile phone terminal, and the second terminal may be a PC terminal. The mobile phone and the PC can perform data communication via a Real Time Messaging Protocol (RTMP). Specifically, the mobile phone end can establish connection with the PC end by scanning a two-dimensional code request of the PC end, the two-dimensional code can be provided by an application installed on the PC end or provided by a web page, and specifically, the application can be an application for live game and electronic contest, and the application has a function of screen projection of the mobile phone. When the mobile phone terminal scans the two-dimensional code of the PC terminal, the mobile phone terminal can acquire the IP address of the PC terminal through the two-dimensional code, and the PC terminal can also acquire the IP address of the mobile phone terminal through a connection establishment request sent by the mobile phone terminal. Under the condition that the connection establishment between the mobile phone and the PC end requested by the mobile phone end fails, the PC end can send a connection establishment request to the mobile phone end according to the IP address of the mobile phone end. Because the problem of a firewall does not exist in the mobile phone end, data connection between the PC end and the mobile phone end can be realized through the reverse connection request of the PC end.

As an optional implementation manner, taking live broadcasting a game picture currently being displayed on a mobile phone interface at a PC end as an example, the PC end installs an application program with a screen projection function, which may be referred to as a first application program. Fig. 2 shows an application main interface with a screen projection function at the PC side. By clicking the screen-projecting control in the interface, a two-dimensional code as shown in fig. 3 is presented in the application program of the PC terminal, and the two-dimensional code carries the IP address of the PC terminal.

The application program with the screen projecting function is installed at the mobile phone end, and may be referred to as a second application program, and as shown in fig. 4, the main interface of the application program with the screen projecting function at the mobile phone end is shown. Selecting a touch button of 'computer screen projection', displaying a 'scanning two-dimensional code' interface as shown in fig. 5 on the interface of the mobile phone end, wherein the two-dimensional code of the PC end scanned by the mobile phone end is a request for establishing connection with the PC end, and the PC end can acquire the IP address of the mobile phone end through the request of the mobile phone end while the two-dimensional code of the PC end is scanned by the mobile phone end. If the firewall of the PC end prevents the connection establishment requested by the mobile phone end, the PC end can return the request for establishing the connection to the mobile phone end through the acquired IP address of the mobile phone end. Because the problem of firewall does not exist in the mobile phone end, the mobile phone end responds to the connection request initiated by the PC end and establishes data connection with the PC end.

Through the steps, the first terminal sends the first connection request to the acquired IP address of the second terminal, and the first connection request is used for requesting to establish the first connection between the first terminal and the second terminal. And under the condition that the first connection is failed to be established, the second terminal sends a second connection establishment request to the first terminal, the second connection establishment request is used for requesting to establish a second connection between the first terminal and the second terminal, and the second connection is established between the first terminal and the second terminal. Therefore, the technical effect of establishing connection between the mobile phone end and the PC end is achieved, and the technical problem that the connection between the mobile phone end and the PC end cannot be established is solved.

Optionally, as an optional implementation manner, the connection establishment method of multiple terminals may be applied, but not limited to, in an environment as shown in fig. 6.

Optionally, in this embodiment, the connection establishment of the multiple terminals may be, but is not limited to, applied to a hardware environment formed by a first terminal, a second terminal, and a background server, where the first terminal may be a mobile phone terminal, the second terminal may be a PC terminal such as a tablet computer and a notebook computer, and the first terminal and the second terminal both support running of an application client. The background server and the first terminal and the second terminal may, but are not limited to, implement data interaction through a network, which may include, but is not limited to, a wireless network or a wired network. Wherein, this wireless network includes: bluetooth, WIFI, and other networks that enable wireless communication. Such wired networks may include, but are not limited to: wide area networks, metropolitan area networks, and local area networks. The above is merely an example, and this is not limited in this embodiment.

As an optional embodiment, the second application program with the screen projection function installed at the mobile phone end obtains the IP address of the local computer, and obtains the IP address of the PC end from the two-dimensional code after scanning the two-dimensional code generated in the second application program installed at the PC end. And then the mobile phone end sends a message to the background server to inform the background server that the mobile phone end wants to establish connection with the PC end, wherein the message carries the IP address of the mobile phone end which wants to establish connection with the PC end.

The second terminal PC end is provided with a screen projection monitoring server, and the PC end can go to a background server to pull information when starting the monitoring server, and can see which mobile phone ends try to be connected to the PC end currently. If yes, the IP address of the mobile phone end is obtained from the background server, and the PC end initiates reverse connection.

And when the mobile phone starts the scanning screen projection function, a network monitoring port is also established to wait for the PC end to be actively connected with the mobile phone end. The PC end is successfully connected to the network monitoring port established by the mobile phone end, and after the RTMP handshake is passed, the network interaction process can follow the standard RTMP protocol.

As an optional embodiment, after sending the first connection establishment request to the second IP address on the first terminal, the method further comprises: and determining that the first connection establishment fails under the condition that the firewall on the second terminal rejects the first connection establishment request. In this embodiment, the firewall is an information security system installed between the internet and an intranet in the field of computer science, and monitors the transmission of traffic according to a policy predetermined by the enterprise. The firewall may be a dedicated network device or run on a host to check for network traffic on each network interface. It is currently the most important network protection device, and from a professional perspective, a firewall is a set of hardware or software components located between two (or more) networks that perform inter-network access or control. And under the condition that the firewall of the PC terminal rejects the connection request initiated by the mobile phone terminal, determining that the connection establishment initiated from the mobile phone terminal to the PC terminal fails. Specifically, the mobile phone or the PC may determine that the connection is failed, and after the mobile phone scans the two-dimensional code, if the firewall of the PC rejects the connection request initiated by the mobile phone, the mobile phone may receive a connection rejection message sent by the PC, and a prompt message of "connection failure" may be displayed on an interface of the mobile phone. After the mobile phone scans the PC end, the PC end acquires information requesting connection, and if connection with the mobile phone end is not established within a predetermined time interval, the PC end determines that connection with the mobile phone end fails, and the predetermined time interval may be set according to actual conditions, for example, 30 seconds, 1 minute, or 3 minutes, and the like.

As an optional embodiment, the obtaining, at the first terminal, the second connection establishment request sent by the second terminal to the first IP address includes: establishing a target monitoring task on the first terminal, wherein the target monitoring task is used for monitoring a connection establishment request sent to the first IP address; and monitoring the second connection establishment request through the target monitoring task on the first terminal. In this embodiment, when the mobile phone sends the connection request to the PC, a network listening task is established at the mobile phone, and specifically, the mobile phone can serve as a temporary listening server through the listening port. Originally, the identity of the PC end of the server is reversed, and a connection request is actively sent to the mobile phone end to connect with the port of the mobile phone end. And monitoring the connection request sent by the PC end through a monitoring task established by the mobile phone end.

As an optional embodiment, the establishing a target listening task on the first terminal includes: establishing a first monitoring task on the first terminal, wherein the target monitoring task comprises the first monitoring task, and the first monitoring task is used for monitoring a connection establishment request sent to a target port of the first IP address; the monitoring the second connection establishment request through the target monitoring task on the first terminal includes: and monitoring the second connection establishment request sent by the second terminal to the target port of the first IP address through the first monitoring task on the first terminal. In this embodiment, a network monitoring port may be established at the mobile phone end to serve as a temporary server, and the monitoring task is used to monitor a connection establishment request sent to the port by the PC end. As an optional implementation manner, while sending the connection request to the PC, the mobile phone obtains its own IP address, for example, 192.168.1.200, and then establishes a monitoring port, for example, 1937, which serves as a temporary server of the mobile phone and is used to monitor whether there is a terminal request to establish a connection with the mobile phone. And under the condition that the monitoring port of the mobile phone end monitors that the PC end requests to establish connection with the mobile phone end, establishing connection with the PC end according to the IP address of the PC end.

As an optional embodiment, the establishing the second connection between the first terminal and the second terminal in response to the second connection establishment request includes: and under the condition that the target port is a TCP port and the second connection establishment request is an RTMP connection establishment request, establishing RTMP connection between the first terminal and the second terminal. In this embodiment, a Real Time Messaging Protocol (RTMP) is a Protocol family based on TCP. RTMP is a network protocol used for real-time data communication, mainly used for audio-video and data communication. The monitoring port can be a TCP port, and when the monitoring port monitors the RTMP connection establishment request sent by the PC terminal, the connection can be successfully established with the PC terminal because the mobile phone terminal does not have the problem of a firewall.

As an optional embodiment, after establishing the second connection between the first terminal and the second terminal in response to the second connection establishment request, the method further comprises: and transmitting the picture information displayed on the screen of the first terminal to the second terminal through the second connection on the first terminal, wherein the picture information is used for displaying on the second terminal. In this embodiment, after the connection between the mobile phone and the PC is successfully established, the PC can display the content displayed on the current screen of the mobile phone. The content displayed on the current screen of the mobile phone terminal can be a game interface which is being operated, and can also be audio and video which is being played. Taking live game as an example, and taking the case that the current screen of the mobile phone displays a game interface, in the game competition process, the game operation of the contestants needs to be displayed on the PC end in a live broadcast manner, and spectators can know the operation of the contestants in the game through live broadcast pictures. The screen projection function of the mobile phone and the PC end can display the game operation executed by the contestant at the mobile phone end at the PC end, however, under normal circumstances, the firewall at the PC end can stop the connection request sent by the mobile phone end, and thus the mobile phone end often cannot establish a connection with the PC end successfully. In this embodiment, a second application program with a screen projection function is started at a mobile phone end, after a computer screen projection function is selected to scan a two-dimensional code in a first program with a screen projection function at a PC end, connection establishment with the PC end is requested, and under the condition that establishment of a connection request sent from the mobile phone end to the PC end fails, the PC end reversely sends the connection request to the mobile phone end.

As an optional embodiment, before the obtaining, on the first terminal, the second connection establishment request sent by the second terminal to the first IP address, the method includes: under the condition that the first connection is failed to be established, acquiring the first IP address of the first terminal on the second terminal; and sending the second connection establishment request to the first IP address on the second terminal. In this embodiment, when initiating connection establishment to a PC, a mobile phone reports an IP address of the mobile phone itself, and when pulling that a connection is expected to be established by the mobile phone and the connection is not successfully established, the PC acquires the IP address of the mobile phone and reversely sends a request for establishing the connection to the IP address of the mobile phone.

As an optional embodiment, the obtaining, at the second terminal, the first IP address of the first terminal includes: and acquiring the first IP address of the first terminal sent by a background server on the second terminal, wherein the first IP address in the background server is uploaded to the background server by the first terminal. In this embodiment, the mobile phone obtains its own IP address, and after the mobile phone scans the two-dimensional code presented by the PC, obtains the IP address of the PC from the two-dimensional code information. Meanwhile, the mobile phone end reports the IP address of the mobile phone end to the background server so as to inform the background server of establishing connection with the PC end. And in a preset time period after the mobile phone terminal scans the two-dimensional code, the PC terminal finds that the connection with the mobile phone is not established, at the moment, the PC terminal pulls information to the server to obtain an IP address of the mobile phone terminal which wants to be connected with the PC terminal, and sends a connection request to the IP address to request the establishment of the connection with the mobile phone terminal.

Alternatively, as an alternative embodiment, the present application is illustrated below by a specific example.

Taking live game as an example, assume that the local area network IP address of the mobile phone is 192.168.1.200, and the local area network IP address of the PC is 192.168.1.201.

The current interface of the mobile phone end is a game interface as shown in fig. 7, and after the mobile phone end selects 'computer screen projection', the two-dimensional code of the PC end is scanned by 'scanning two-dimensional code'.

The mobile phone end establishes a TCP listening port, for example, 1935. And then scanning the two-dimensional code of the PC end by scanning the two-dimensional code at the mobile phone end, obtaining the IP address 192.168.1.201 of the PC end from the two-dimensional code, reporting the IP address 192.168.1.200 of the mobile phone end and the created monitoring port 1935 to a background server by the mobile phone end, and informing the background server that the mobile phone terminal with the IP address of 192.168.1.200 wants to establish connection with the PC terminal with the IP address of 192.168.1.201.

Under the condition that no firewall problem exists, as shown in fig. 8, after the interaction processes of C0/C1/C2/S1/S2 and the like are completed, the RTMP handshake is formally completed, and the mobile phone end and the PC end successfully establish a connection, so that the PC end can receive the picture data from the mobile phone end.

However, when there is a firewall problem at the PC, the TCP packet sent by the mobile phone cannot arrive smoothly, so that the PC does not receive any C0/C1/C2 packet, and the connection is over time, and finally the connection fails, as shown in fig. 9.

In this embodiment, the PC will pull information to the backend server at predetermined intervals to see which mobile phones are trying to establish connection with the PC currently. The PC terminal with IP address 192.168.1.201 wants to establish a connection with the mobile phone terminal with IP address 192.168.1.200 obtained from the background server. And the PC terminal detects that the connection with the mobile phone terminal with the IP address is not established in a preset time period, and then the PC terminal reversely sends a connection establishment request to the mobile phone terminal with the IP address of 192.168.1.200.

The mobile phone monitors the connection request sent by the PC through the established monitoring port 1937, as shown in fig. 10, the connection can be established smoothly because the mobile phone does not have the firewall problem, and after the mobile phone and the PC are successfully connected, the PC can live broadcast the content displayed in the current mobile phone interface.

In this embodiment, the mobile phone reads the IP address of the PC terminal by scanning the code to initiate the connection. Then, the PC end needs to initiate a connection to the mobile phone end, and first obtains the IP address of the mobile phone. The specific solution is as follows:

firstly, the mobile phone end acquires a local IP (Internet protocol), such as 192.168.1.200, then establishes an available port, such as 1937, and obtains an IP address 192.168.1.201 of the PC from the two-dimensional code information after scanning the PC. The handset then calls the backend server, telling the backend 192.168.1.200 that it wants to establish a connection with 192.168.1.201, and the listening port is 1937. The PC receives the information sent by the background server, knows that a mobile phone wants to screen, the IP address of the mobile phone is 192.168.1.200, and the monitored port is 1937, so that RTMP connection is actively initiated to 192.168.1.200: 1937. And establishing RTMP connection, and then normally performing mobile phone screen projection service.

By adopting the scheme, the connection rate of screen projection of the mobile phone is improved, the problem of connection failure caused by a firewall under the same local area is avoided, the firewall configuration steps are reduced in operation experience, firewall configuration is avoided conveniently, user experience is greatly improved, the workload of customer service and operation on screen projection is reduced, and the user public praise is improved.

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

According to another aspect of the embodiments of the present invention, there is also provided a multi-terminal connection establishing apparatus for implementing the multi-terminal connection establishing method. As shown in fig. 11, the apparatus includes:

a first obtaining module 1102, configured to obtain, on the first terminal, a second IP address of the second terminal; a sending module 1104, configured to send a first connection establishment request to the second IP address on the first terminal, where the first connection establishment request carries a first IP address of the first terminal, and the first connection establishment request is used to request establishment of a first connection between the first terminal and the second terminal; a second obtaining module 1106, configured to obtain, on the first terminal, a second connection establishment request sent by the second terminal to the first IP address when the first connection establishment fails, where the second connection establishment request is used to request that a second connection is established between the first terminal and the second terminal; an establishing module 1108, configured to establish the second connection between the first terminal and the second terminal in response to the second connection establishing request.

As an optional embodiment, the apparatus is further configured to determine that the first connection establishment fails when a firewall on the second terminal rejects the first connection establishment request after the first terminal sends the first connection establishment request to the second IP address.

As an optional embodiment, the second obtaining module is further configured to obtain, on the first terminal, a second connection establishment request sent by the second terminal to the first IP address by: establishing a target monitoring task on the first terminal, wherein the target monitoring task is used for monitoring a connection establishment request sent to the first IP address; and monitoring the second connection establishment request through the target monitoring task on the first terminal.

As an optional embodiment, the apparatus is configured to establish the target listening task on the first terminal by: establishing a first monitoring task on the first terminal, wherein the target monitoring task comprises the first monitoring task, and the first monitoring task is used for monitoring a connection establishment request sent to a target port of the first IP address; the above apparatus is configured to implement that the monitoring of the second connection establishment request by the target listening task on the first terminal is performed in the following manner: and monitoring the second connection establishment request sent by the second terminal to the target port of the first IP address through the first monitoring task on the first terminal.

As an optional embodiment, the establishing module is configured to establish the second connection between the first terminal and the second terminal in response to the second connection establishment request by: and under the condition that the target port is a TCP port and the second connection establishment request is an RTMP connection establishment request, establishing RTMP connection between the first terminal and the second terminal.

As an optional embodiment, the apparatus is further configured to, after establishing the second connection between the first terminal and the second terminal in response to the second connection establishment request, transmit, on the first terminal, screen information displayed on a screen of the first terminal to the second terminal through the second connection, where the screen information is for display on the second terminal.

As an optional embodiment, the apparatus is further configured to, before obtaining, on the first terminal, a second connection establishment request sent by the second terminal to the first IP address, obtain, on the second terminal, the first IP address of the first terminal in a case that the first connection establishment fails; and sending the second connection establishment request to the first IP address on the second terminal.

As an optional embodiment, the apparatus is further configured to implement the acquiring, at the second terminal, the first IP address of the first terminal by: and acquiring the first IP address of the first terminal sent by a background server on the second terminal, wherein the first IP address in the background server is uploaded to the background server by the first terminal.

According to another aspect of the embodiments of the present invention, there is also provided an electronic apparatus for implementing the method for establishing a connection between multiple terminals, as shown in fig. 12, the electronic apparatus includes a memory 1202 and a processor 1204, the memory 1202 stores therein a computer program, and the processor 1204 is configured to execute the steps in any one of the method embodiments through the computer program.

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

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

s1, acquiring a second IP address of a second terminal on the first terminal;

s2, sending a first connection establishment request to the second IP address on the first terminal, where the first connection establishment request carries a first IP address of the first terminal, and the first connection establishment request is used to request establishment of a first connection between the first terminal and the second terminal;

s3, when the first connection is failed to be established, obtaining, at the first terminal, a second connection establishment request sent by the second terminal to the first IP address, where the second connection establishment request is used to request to establish a second connection between the first terminal and the second terminal;

s4, in response to the second connection establishment request, establishing the second connection between the first terminal and the second terminal.

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

The memory 1202 may be configured to store software programs and modules, such as program instructions/modules corresponding to the method and apparatus for establishing a connection between multiple terminals in the embodiment of the present invention, and the processor 1204 executes various functional applications and data processing by running the software programs and modules stored in the memory 1202, that is, implements the method for establishing a connection between multiple terminals. The memory 1202 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 1202 can further include memory located remotely from the processor 1204, which can be connected to a terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.

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

In addition, the electronic device further includes: a display 1208, configured to display the first connection establishment request or the second connection establishment request; and a connection bus 1210 for connecting the respective module parts in the above-described electronic apparatus.

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

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

s1, acquiring a second IP address of a second terminal on the first terminal;

s2, sending a first connection establishment request to the second IP address on the first terminal, where the first connection establishment request carries a first IP address of the first terminal, and the first connection establishment request is used to request establishment of a first connection between the first terminal and the second terminal;

s3, when the first connection is failed to be established, obtaining, at the first terminal, a second connection establishment request sent by the second terminal to the first IP address, where the second connection establishment request is used to request to establish a second connection between the first terminal and the second terminal;

s4, in response to the second connection establishment request, establishing the second connection between the first terminal and the second terminal.

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

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

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

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

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

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

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

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

20页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:接收参考信号的方法和通信设备

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!