Equipment connection method and device and electronic equipment
By obtaining and using the pre-stored IP addresses and identifications of the connected device, directly establishing a connection with the connected device, the problem of cumbersome connection process in the prior art is solved, the connection efficiency is improved and user operations are simplified.
Patent Information
- Application Number
- CN202311247833.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2043-09-26
AI Technical Summary
In the prior art, the process of establishing a network connection between the connected device and the connected device requires the user to manually input parameters such as the IP address of the connected device, resulting in a cumbersome connection process.
By obtaining the IP address and identification of the connected device corresponding to the pre-stored shortcut, a connection is directly established with the connected device to avoid user manually entering parameters.
It improves the efficiency of establishing connections between the connected devices and the connected devices, simplifies the connection process, and reduces the complexity of user operations.
Smart Images

Figure CN119729901A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network communication technology, and in particular to a device connection method, apparatus and electronic device. Background Art
[0002] Currently, when a connecting device establishes a network connection with a connected device, the connection method used is: the user manually enters parameters such as the IP address of the connected device in the connecting device, and then the connecting device establishes a network connection with the connected device based on the parameters entered by the user.
[0003] However, the above method requires manual input by the user, and the process of establishing a network connection between the connecting end device and the connected end device is relatively cumbersome. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a device connection method, apparatus and electronic device to improve the efficiency of establishing a connection between a connecting end device and a connected end device. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present application provides a device connection method, which is applied to a connection end device, and the method includes:
[0006] When a connection instruction for a shortcut corresponding to a connected end device is obtained, an IP address and an identifier of the connected end device corresponding to the shortcut stored in advance are obtained;
[0007] A connection is established with the connected end device based on the IP address of the connected end device and the connected end device identifier.
[0008] Optionally, establishing a connection with the connected end device based on the IP address and the connected end device identifier of the connected end device includes:
[0009] Sending a network connection request to the IP address of the connected end device;
[0010] If the network connection with the connected end device fails through the IP address, the alternative device identification is obtained through the preset device detection method;
[0011] If the connected-end device identifier exists in the candidate device identifiers, a connection request is sent to the connected-end device to establish a connection with the connected-end device.
[0012] Optionally, the detecting and obtaining the candidate device identification by a preset device detection method includes:
[0013] Obtaining, by multicast detection, an identifier of a device in the same network as the connection end device as a candidate device identifier; or, by wireless network direct connection, detecting and obtaining, by wireless network direct connection, an identifier of a device with a wireless network direct connection function enabled within a preset range of the connection end device as a candidate device identifier;
[0014] The sending a connection request to the connected end device to establish a connection with the connected end device includes:
[0015] In the case where the multicast detects the connected end device identifier, obtaining the IP address of the connected end device based on the multicast return; sending a network connection request to the connected end device based on the IP address returned by the multicast, so as to establish a network connection with the connected end device; or,
[0016] When the wireless network direct connection detects the connected end device identifier, a wireless network connection request is sent to the connected end device through the wireless network direct connection mode to establish a wireless network connection with the connected end device.
[0017] Optionally, the method further includes:
[0018] In the case where the multicast fails to detect the identification of the connected end device, the identification of a device with the wireless network direct connection function enabled within a preset range of the connecting end device is detected by wireless network direct connection as a candidate device identification; or
[0019] In the case that the wireless network direct connection fails to detect the identification of the connected end device, the identification of a device in the same network as the connecting end device is obtained through multicast detection as a candidate device identification.
[0020] Optionally, before the method of detecting and obtaining the candidate device identifier by a preset device detection method if the network connection with the connected end device by using the IP address fails, the method further includes:
[0021] In the case where it is determined that the IP address is unavailable based on the response to the network connection request, determining that the network connection with the connected end device fails; or,
[0022] When it is determined that the IP address is available based on the response to the network connection request, a device identifier corresponding to the IP address is obtained. When the obtained device identifier is different from the connected device identifier, it is determined that the network connection with the connected device has failed.
[0023] Optionally, after establishing the connection with the connected end device, the method further includes:
[0024] Based on the IP address of the connected end device corresponding to the successfully established connection, the pre-stored IP address of the connected end device corresponding to the shortcut is updated.
[0025] Optionally, the connected device identifier is generated based on the hardware serial number of the connected device, the initial MAC address of the connected device, or is randomly generated, and the connected device identifier is used to uniquely identify the connected device and is fixed; and / or,
[0026] The establishing a connection with the connected end device based on the IP address and the connected end device identifier of the connected end device includes:
[0027] Sending a network connection request to the IP address of the connected end device;
[0028] When it is determined that the IP address is available based on the response to the network connection request, obtaining a device identifier corresponding to the IP address, and if the obtained device identifier is the same as the connected device identifier, sending a network connection request to the connected device via the IP address of the connected device to establish a network connection; and / or,
[0029] The connecting end device also stores the port information of the connected end device corresponding to the shortcut. After establishing the connection with the connected end device, the method further includes:
[0030] A connection is established with a target application installed in the connected end device based on the port information.
[0031] In a second aspect, an embodiment of the present application provides a device connection apparatus, which is applied to a connection end device, and the device includes:
[0032] An information acquisition module, configured to acquire, when a connection instruction for a shortcut corresponding to a connected end device is acquired, an IP address of the connected end device and a connected end device identifier corresponding to the shortcut stored in advance;
[0033] The connection establishment module is used to establish a connection with the connected end device based on the IP address of the connected end device and the connected end device identifier.
[0034] Optionally, the connection establishment module includes:
[0035] A network connection request sending unit, used to send a network connection request to the IP address of the connected end device;
[0036] A first detection unit, configured to detect and obtain an alternative device identifier by a preset device detection method when the network connection with the connected end device via the IP address fails;
[0037] The connection establishing unit is used to send a connection request to the connected end device when the connected end device identifier exists in the candidate device identifier, so as to establish a connection with the connected end device.
[0038] Optionally, the first detection unit is specifically used to obtain, through multicast detection, an identifier of a device in the same network as the connection end device as a candidate device identifier; or, through a wireless network direct connection method, detect and obtain, as a candidate device identifier, an identifier of a device that enables a wireless network direct connection function within a preset range of the connection end device;
[0039] The connection establishment unit is specifically used to obtain the IP address of the connected device based on the multicast return when the multicast detects the connected device identifier; send a network connection request to the connected device based on the IP address returned by the multicast through the connected device to establish a network connection with the connected device; or, when the wireless network direct connection detects the connected device identifier, send a wireless network connection request to the connected device through the wireless network direct connection to establish a wireless network connection with the connected device.
[0040] Optionally, the connection establishment module further includes a second detection unit;
[0041] The second detection unit is used to detect and obtain the identification of a device that enables the wireless network direct connection function within a preset range of the connecting end device through a wireless network direct connection method when the multicast fails to detect the identification of the connected end device, as an alternative device identification; or, when the wireless network direct connection fails to detect the identification of the connected end device, obtain the identification of a device in the same network as the connecting end device through multicast detection, as an alternative device identification.
[0042] Optionally, the connection establishment module further includes a connection status determination unit;
[0043] The connection status determination unit is used to determine that the network connection with the connected device has failed when it is determined that the IP address is unavailable based on the response to the network connection request; or to obtain a device identifier corresponding to the IP address when it is determined that the IP address is available based on the response to the network connection request, and determine that the network connection with the connected device has failed when the obtained device identifier is different from the connected device identifier.
[0044] Optionally, the device further comprises:
[0045] The IP address updating module is used to update the pre-stored IP address of the connected end device corresponding to the shortcut based on the IP address of the connected end device corresponding to the successfully established connection after establishing a connection with the connected end device.
[0046] Optionally, the connected device identifier is generated based on the hardware serial number of the connected device, the initial MAC address of the connected device, or is randomly generated, and the connected device identifier is used to uniquely identify the connected device and is fixed; and / or,
[0047] The connection establishment module is specifically configured to send a network connection request to the IP address of the connected end device; if it is determined that the IP address is available based on the response to the network connection request, obtain a device identifier corresponding to the IP address; if the obtained device identifier is the same as the connected end device identifier, send a network connection request to the connected end device through the IP address of the connected end device to establish a network connection; and / or,
[0048] The connecting end device also stores the port information of the connected end device corresponding to the shortcut, and the apparatus further comprises a program connection module;
[0049] The program connection module is used to establish a connection with a target application installed in the connected end device based on the port information after the connection with the connected end device is established.
[0050] In a third aspect, an embodiment of the present application provides an electronic device, including:
[0051] Memory, used to store computer programs;
[0052] The processor is used to implement any method described in the first aspect when executing a program stored in the memory.
[0053] Beneficial effects of the embodiments of the present application:
[0054] In the solution provided by the embodiment of the present application, when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can obtain the IP address and the connected end device identifier corresponding to the pre-stored shortcut; and establish a connection with the connected end device based on the IP address and the connected end device identifier of the connected end device. Since when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can directly establish a connection with the connected end device based on the IP address and the connected end device identifier corresponding to the pre-stored shortcut, there is no need for the user to manually input parameters such as the IP address of the connected end device, thereby improving the efficiency of establishing a connection between the connecting end device and the connected end device.
[0055] Of course, implementing any product or method of the present application does not necessarily require achieving all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0057] Figure 1 A flow chart of a device connection method provided in an embodiment of the present application;
[0058] Figure 2 Based on Figure 1 A flow chart of a connection establishment method of the illustrated embodiment;
[0059] Figure 3 Based on Figure 2 A flow chart of a method of establishing a connection through device detection in the illustrated embodiment;
[0060] Figure 4 Based on Figure 2 Another flow chart of the manner of establishing a connection through device detection in the illustrated embodiment;
[0061] Figure 5 Based on Figure 3 A specific flow chart of the method of establishing a connection through device detection in the illustrated embodiment;
[0062] Figure 6 Based on Figure 4 A specific flow chart of the method of establishing a connection through device detection in the illustrated embodiment;
[0063] Figure 7 Based on Figure 2A specific flow chart of the connection establishment method of the illustrated embodiment;
[0064] Figure 8 A specific flow chart of a device connection method provided in an embodiment of the present application;
[0065] Fig. 9 A schematic diagram of the structure of a device connection device provided in an embodiment of the present application;
[0066] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0067] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field based on the present application belong to the scope of protection of the present application.
[0068] In order to improve the efficiency of establishing a connection between a connecting end device and a connected end device, an embodiment of the present application provides a device connection method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product. The following first introduces a device connection method provided in an embodiment of the present application.
[0069] The device connection method provided in the embodiment of the present application can be applied to any connecting end device that needs to establish a connection with a connected end device, for example, it can be a computer, a tablet computer, a mobile phone, etc., which is not specifically limited here. For the sake of clarity, it is hereinafter referred to as the connecting end device.
[0070] like Figure 1 As shown, a device connection method is applied to a connection end device, and the method includes:
[0071] S101, when a connection instruction for a shortcut corresponding to a connected end device is obtained, an IP address and a connected end device identifier of the connected end device corresponding to the shortcut that are pre-stored are obtained.
[0072] S102: Establish a connection with the connected end device based on the IP address and the connected end device identifier of the connected end device.
[0073] In the solution provided by the embodiment of the present application, when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can obtain the IP address and the connected end device identifier corresponding to the pre-stored shortcut; and establish a connection with the connected end device based on the IP address and the connected end device identifier of the connected end device. Since when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can directly establish a connection with the connected end device based on the IP address and the connected end device identifier corresponding to the pre-stored shortcut, there is no need for the user to manually input parameters such as the IP address of the connected end device, thereby improving the efficiency of establishing a connection between the connecting end device and the connected end device.
[0074] After the connecting device establishes a connection with the connected device for the first time, it can obtain the IP address and the connected device identifier of the connected device, and then generate a shortcut corresponding to the connected device based on the IP address and the connected device identifier of the connected device. In this way, when the connecting device subsequently wants to establish a connection with the connected device again, it can start the shortcut corresponding to the connected device, and complete the relevant pre-sequence operations and relevant post-sequence operations of establishing the connection through the shortcut, thereby realizing a quick connection with the connected device.
[0075] Therefore, when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can start the shortcut and obtain the pre-stored IP address and connected end device identifier of the connected end device corresponding to the shortcut.
[0076] In one embodiment, when the connecting-end device generates a shortcut corresponding to the connected-end device based on the IP address and the connected-end device identifier of the connected-end device, the IP address and the connected-end device identifier of the connected-end device can be written into the startup parameters of the shortcut corresponding to the connected-end device. In this way, when the connecting-end device obtains the connection instruction for the shortcut corresponding to the connected-end device, it can read the IP address and the connected-end device identifier of the connected-end device from the startup parameters of the shortcut.
[0077] After obtaining the IP address and the connected device identifier of the connected device, the connecting device can establish a connection with the connected device based on the IP address and the connected device identifier of the connected device. Specifically, the connecting device can first establish a network connection with the connected device based on the IP address of the connected device through the shortcut corresponding to the connected device. If the network connection fails to be established, it means that the IP address of the connected device may have changed. At this time, the connecting device can find the connected device based on the fixed connected device identifier, thereby establishing a connection with the connected device.
[0078] In one embodiment, when the connection between the connecting end device and the connected device is a connection between an application in the connecting end device and an application in the connected device, the connecting end device may also pre-store port information of the connected end device corresponding to the shortcut. On this basis, when the connecting end device establishes a connection with the connected end device, it may first establish a connection between the devices through the IP address and the device identifier, and then establish a connection between the device and the application in the device according to the port number, thereby realizing the connection between the application in the connecting end device and the application in the connected device.
[0079] In the solution provided by the embodiment of the present application, when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can directly establish a connection with the connected end device based on the IP address of the connected end device and the connected end device identifier corresponding to the pre-stored shortcut, without the need for the user to manually input parameters such as the IP address of the connected end device, thereby improving the efficiency of the connecting end device and the connected end device to establish a connection. In addition, when the IP address of the connected end device has not changed, the connecting end device can directly establish a connection with the connected end device based on the acquired IP address through the shortcut. When the IP address of the connected end device changes, the connecting end device can also establish a connection with the connected end device based on the acquired connected end device identifier, because the connected end device identifier will not change, so even if the MAC address of the connected end device changes, the connecting end device can also find the connected end device based on the fixed connected end device identifier, thereby establishing a connection, thereby improving the success rate of the connecting end device establishing a connection with the connected end device through the shortcut.
[0080] As an implementation method of the present application, Figure 2 As shown, the above-mentioned establishing a connection with the connected end device based on the IP address of the connected end device and the connected end device identifier may include:
[0081] S201, sending a network connection request to the IP address of the connected end device.
[0082] After obtaining the IP address and the connected device identifier of the connected device, the connecting device may first send a network connection request to the IP address of the connected device to determine whether the IP address is available.
[0083] In one embodiment, the connecting device can send a network connection request to the IP address of the connected device, and then monitor whether response data from the connected device is received within a preset time period. If response data from the connected device is received within the preset time period, it is determined that the IP address is available; if no response data from the connected device is received within the preset time period, it is determined that the IP address is unavailable.
[0084] S202: If the network connection with the connected device via the IP address fails, obtain an alternative device identifier via a preset device detection method.
[0085] If the connecting device cannot establish a network connection with the connected device through the IP address of the connected device, that is, the network connection fails, it means that the IP address of the connected device may have changed, and the network connection with the connected device can no longer be established based on the pre-stored IP address of the connected device.
[0086] However, at this time, the connected device may still be in the same network as the connecting device, or in the preset range of the connecting device. In this case, the connected device can detect the identifiers of each device in the same network as the connecting device through a preset device detection method, or detect the identifiers of each device within the preset range of the connecting device, and use them as alternative device identifiers.
[0087] S203: If the connected-end device identifier exists in the candidate device identifiers, send a connection request to the connected-end device to establish a connection with the connected-end device.
[0088] Because there may be multiple devices that are in the same network as the connecting device or within the preset range of the connecting device, and the connected device may or may not exist among these devices, the connecting device can determine whether the connected device identifier exists among the alternative device identifiers after detecting each alternative device identifier, that is, determine whether the connected device exists among the devices that are in the same network as the connecting device or within the preset range of the connecting device.
[0089] If the connected device identifier exists in the alternative device identifiers, it means that the connected device is in the same network as the connecting device, or the connected device exists among the devices within the preset range of the connecting device. Therefore, after determining that the connected device identifier exists in the alternative device identifier, the connecting device can determine the device corresponding to the connecting device identifier based on the connected device identifier, use it as the connected device, and then send a connection request to the connected device to establish a connection with the connected device.
[0090] Among them, the connecting-end device sends a connection request to the connected-end device to establish a connection with the connected-end device. The method can be to send a connection request to the connected-end device through a preset connection method and then directly establish a connection with the connected-end device, or it can be to first send a connection request to the connected-end device to obtain the IP address of the connecting-end device, and then establish a network connection with the connected-end device based on the IP address. No specific limitation is made here.
[0091] If the connected device identifier does not exist in the alternative device identifiers, it means that the connected device is in the same network as the connecting device, or the connected device does not exist among the devices within the preset range of the connecting device. Therefore, after determining that the connected device identifier does not exist in the alternative device identifiers, the connecting device can determine that the connection has failed.
[0092] In the solution provided by the embodiment of the present application, after obtaining the IP address and the connected device identifier of the connected device, the connecting device can first try to establish a network connection with the connected device based on the IP address of the connected device. If the network connection can be established, a simple and efficient quick connection can be achieved. If the network connection cannot be established, the connecting device can also detect and obtain the identifiers of each candidate device based on the preset device detection method, and then determine whether the connected device is detected based on the connected device identifier. If it is detected, it can establish a connection with the connected device based on the connected device identifier, thereby improving the success rate of the connecting device establishing a connection with the connected device through a shortcut.
[0093] As an implementation of the embodiment of the present application, the above-mentioned detection and obtaining of the candidate device identification by the preset device detection method may include:
[0094] The identification of a device in the same network as the connecting end device is obtained through multicast detection as a candidate device identification; or, through a wireless network direct connection method, the identification of a device with a wireless network direct connection function enabled within a preset range of the connecting end device is obtained through detection as a candidate device identification.
[0095] Accordingly, the establishing a connection with the connected end device based on the connected end device identifier may include:
[0096] In the case where the multicast detects the connected device identifier, the IP address of the connected device returned based on the multicast is obtained; the connected device sends a network connection request to the connected device based on the IP address returned by the multicast to establish a network connection with the connected device; or, in the case where the wireless network direct connection detects the connected device identifier, a wireless network connection request is sent to the connected device through the wireless network direct connection to establish a wireless network connection with the connected device.
[0097] In one embodiment, after the connecting end device fails to connect to the network of the connected end device through the IP address of the connected end device, the connecting end device detects through a preset device detection method, and the method of establishing a connection with the connected end device can be as follows: Figure 3 As shown:
[0098] S301, obtaining, through multicast detection, an identifier of a device in the same network as the connection end device as a candidate device identifier.
[0099] After the connecting device fails to establish a network connection with the connected device through the IP address of the connected device, the connecting device can enable the multicast function and obtain the identification of the device in the same network as the connecting device through multicast detection as an alternative device identification.
[0100] S302, determining whether the connected end device identifier exists in the candidate device identifiers, if so, executing step S303; if not, determining that the connection fails.
[0101] After detecting and obtaining the candidate device identifier, the connecting end device can determine whether the connected end device identifier exists in the candidate device identifier, that is, determine whether the connected end device exists in each device in the same network as the connecting end device.
[0102] S303, obtaining the IP address of the connected device based on the multicast return; sending a network connection request to the connected device through the connected device based on the IP address returned by the multicast, so as to establish a network connection with the connected device.
[0103] When the connecting device detects the connected device identifier in multicast, that is, when the connected device identifier exists in the alternative device identifiers, the connecting device can obtain the IP address of the device corresponding to the connected device identifier, that is, obtain the IP address of the connected device, and then the connecting device can send a network connection request to the connected device based on the IP address to establish a network connection with the connected device.
[0104] In one case, the device's response data to the multicast may include the device's IP address. In this way, after the connecting device determines that the connected device identifier exists in the alternative device identifiers, the connecting device can parse the multicast response data of the device corresponding to the connected device identifier, that is, parse the connected device's response data to the multicast to obtain the IP address of the connected device.
[0105] When the connection between the connecting device and the connected device is a connection between an application in the connecting device and an application in the connected device, the response data may also include a port number used by the application in the connected device.
[0106] In another case, the device's response data to the multicast does not include the IP address of the device. In this way, after the connecting-end device determines that the connected-end device identifier exists in the alternative device identifiers, it can send an IP address acquisition request to the device corresponding to the connected-end device identifier, that is, the connected-end device, so that the connected-end device returns the IP address to the connecting-end device based on the IP address acquisition request, so that the connecting-end device can obtain the IP address of the connected-end device.
[0107] In another embodiment, after the connecting end device fails to connect to the network of the connected end device through the IP address of the connected end device, the connecting end device detects through a preset device detection method, and the method of establishing a connection with the connected end device can be as follows: Figure 4 As shown:
[0108] S401, using a wireless network direct connection method, detecting and obtaining an identifier of a device with a wireless network direct connection function enabled within a preset range of the connection end device as a candidate device identifier.
[0109] After the connecting device fails to establish a network connection with the connected device through the IP address of the connected device, it can determine whether it supports the wireless network direct connection function, that is, determine whether it supports the Wi-Fi Direct function. If it does, the wireless network direct connection function is turned on. The identification of the device with the wireless network direct connection function turned on within the preset range of the connecting device is detected through the wireless network direct connection method as an alternative device identification.
[0110] S402, determining whether the connected end device identifier exists in the candidate device identifiers, if yes, executing step S403; if no, determining that the connection fails.
[0111] After detecting the candidate device identifier, the connecting device can determine whether there is a connected device identifier in the candidate device identifier, that is, determine whether there is a connected device in each device with the wireless network direct connection function enabled within a preset range of the connecting device.
[0112] S403: Send a wireless network connection request to the connected end device in a wireless network direct connection manner to establish a wireless network connection with the connected end device.
[0113] When the connecting device detects the connected device identifier through wireless network direct connection, that is, when the connected device identifier exists in the alternative device identifier, it can directly send a wireless network connection request to the connected device through wireless network direct connection to establish a wireless network connection with the connected device, that is, establish a Wi-Fi Direct connection with the connected device through wireless network direct connection, without obtaining the IP address of the connected device.
[0114] In the solution provided in the embodiment of the present application, after the connecting device fails to establish a network connection with the connected device through the IP address of the connected device, the connecting device can choose to detect the device identifier of a device in the same network as the connecting device through multicast, or choose to detect the device identifier of a device with the wireless network direct connection function enabled within a preset range of the connecting device through wireless network direct connection. Then, when the connected device identifier exists in the detected device identifier, the connecting device can be connected to the connected device, thereby improving the success rate of the connecting device in establishing a connection with the connected device through a shortcut.
[0115] As an implementation method of the present application, Figure 5 As shown, after the above step S302, the above method may further include:
[0116] S304: Detect and obtain, by wireless network direct connection, an identifier of a device with a wireless network direct connection function enabled within a preset range of the connection end device as a candidate device identifier.
[0117] After the connecting device fails to establish a network connection with the connected device through the IP address of the connected device, if the connected device identifier is not detected through multicast, that is, the connected device identifier does not exist in the alternative device identifiers detected by multicast, in order to ensure that the connecting device and the connected device are successfully connected, the connecting device can detect the connected device again through the wireless network direct connection method.
[0118] Specifically, the connecting device can determine whether it supports the wireless network direct connection function. If it does, it will turn on the wireless network direct connection function and detect the identification of the device with the wireless network direct connection function turned on within the preset range of the connecting device through the wireless network direct connection method as the alternative device identification.
[0119] S305, determining whether the connected end device identifier exists in the candidate device identifiers, if yes, executing step S306; if not, executing step S307.
[0120] S306: Send a wireless network connection request to the connected end device in a wireless network direct connection manner to establish a wireless network connection with the connected end device.
[0121] The above steps S305-S306 are respectively the same as the above steps S402-S403, and will not be repeated here.
[0122] S307, Connection failed.
[0123] If the connected device identifier does not exist in any of the alternative device identifiers detected by the multicast and wireless network direct connection methods, it means that the connected device is in the same network and that the connected device does not exist in any of the devices within the preset range of the connected device. Therefore, after executing step S305 and determining that the connected device identifier does not exist in the alternative device identifiers, the connecting device can execute step S307 to determine that the connection has failed.
[0124] In the solution provided in the embodiment of the present application, after the connecting device fails to establish a network connection with the connected device through the IP address of the connected device, the connecting device can first detect the connected device identifier through multicast. If multicast cannot detect the connected device identifier, the connected device identifier can be further detected through a wireless network direct connection method, so that the connected device can be detected respectively in the dimension of network distance and the dimension of actual distance, so as to improve the probability of discovering the connected device, thereby improving the success rate of the connecting device in establishing a connection with the connected device through a shortcut.
[0125] As an implementation method of the present application, Figure 6 As shown, after the above step S402, the above method may further include:
[0126] S404: Obtain, through multicast detection, an identifier of a device in the same network as the connection end device as a candidate device identifier.
[0127] After the connecting device fails to establish a network connection with the connected device through the IP address of the connected device, if the connected device identifier is not detected through the wireless network direct connection, that is, the connected device identifier does not exist among the alternative device identifiers detected by the wireless network direct connection, in order to ensure that the connecting device and the connected device are successfully connected, the connecting device can detect the connected device again through multicast.
[0128] Specifically, the connection end device may enable the multicast function, and obtain the identifier of a device in the same network as the connection end device through multicast detection as a candidate device identifier.
[0129] S405, determining whether the connected end device identifier exists in the candidate device identifiers, if yes, executing step S406; if no, executing step S407.
[0130] S406, obtaining the IP address returned by the connected device based on the multicast; sending a network connection request to the connected device through the connected device based on the IP address returned by the multicast, so as to establish a network connection with the connected device.
[0131] The above steps S405-S406 are respectively the same as the above steps S302-S303, and will not be repeated here.
[0132] S407, Connection failed.
[0133] If the connected device identifier does not exist in any of the alternative device identifiers detected by the multicast and wireless network direct connection methods, it means that the connected device is in the same network and that the connected device does not exist in any of the devices within the preset range of the connected device. Therefore, after executing step S405 and determining that the connected device identifier does not exist in the alternative device identifiers, the connecting device can execute step S407 to determine that the connection has failed.
[0134] In the solution provided in the embodiment of the present application, after the connecting device fails to establish a network connection with the connected device through the IP address of the connected device, the connecting device can first detect the connected device identifier through the wireless network direct connection method. If the wireless network direct connection method cannot detect the connected device identifier, the connected device identifier can be further detected through multicast, so that the connected device can be detected respectively in the dimension of network distance and the dimension of actual distance, so as to improve the probability of discovering the connected device, thereby improving the success rate of the connecting device in establishing a connection with the connected device through a shortcut.
[0135] As an implementation method of the present application, Figure 7 As shown, before the above step S202, the method may further include:
[0136] S701, determine whether the IP address is available based on the response of the network connection request, if available, execute step S702, if not available, execute step S202.
[0137] After sending a network connection request to the IP address of the connected device, the connecting device can determine whether the IP address is available based on the response of the IP address to the network connection request.
[0138] For example, after sending a network connection request to the IP address of the connected device, the connecting device can monitor whether response data from the connected device is received within a preset time period. If response data from the connected device is received within the preset time period, it is determined that the IP address is available; if no response data from the connected device is received within the preset time period, it is determined that the IP address is unavailable.
[0139] If it is determined based on the response to the network connection request that the IP address is unavailable, it can be determined that the network connection with the connected device has failed, and the connecting device can then execute step S202, and when the network connection with the connected device via the IP address fails, obtain an alternative device identifier via a preset device detection method.
[0140] If it is determined based on the response to the network connection request that the IP address is available, the connecting device may execute steps S702-S703 to further determine whether the device currently using the IP address is the connected device.
[0141] S702: Obtain a device identifier corresponding to the IP address.
[0142] When the connection end device determines that the IP address is available, it can further obtain the device identification corresponding to the IP address, that is, obtain the device identification of the device currently using the IP address.
[0143] In one embodiment, the device's response data to the network connection request may include the IP address of the device. In this way, after receiving the response data returned from the above-mentioned IP address, the connection-end device can, on the one hand, determine that the IP address is available, and on the other hand, can parse the response data to obtain the device identifier corresponding to the IP address.
[0144] In another embodiment, the device's response data to the network connection request may not include the IP address of the device. In this way, after receiving the response data returned from the above-mentioned IP address and determining that the IP address is available, the connecting end device can send an IP address acquisition request to the device corresponding to the IP address, so that the device corresponding to the IP address returns the IP address to the connecting end device based on the IP address acquisition request, so that the connecting end device can obtain the device identifier corresponding to the IP address.
[0145] S703, determine whether the acquired device identification is the same as the connected end device identification, if they are the same, execute step S704, if they are not the same, execute step S202.
[0146] If the device identifier corresponding to the IP address is obtained, it means that there is currently a device using the IP address of the connected device, but the device may be the connected device or another device. Therefore, after obtaining the device identifier corresponding to the IP address, the connecting device can compare the obtained device identifier with the connected device identifier corresponding to the pre-stored shortcut to determine whether the two are the same, that is, to determine whether the device currently using the IP address is the connected device.
[0147] If the acquired device identifier is different from the connected device identifier, it means that the device currently using the IP address is not the connected device, and it is determined that the network connection with the connected device has failed. The connecting device can then execute step S202, and when the network connection with the connected device via the IP address fails, obtain an alternative device identifier by detecting via a preset device detection method.
[0148] If the acquired device identifier is different from the connected device identifier, it means that the device currently using the IP address is the connected device. At this time, the connecting device can execute step S704.
[0149] S704: Send a network connection request to the connected device through the IP address of the connected device to establish a network connection with the connected device.
[0150] If the connecting device determines that the IP address of the connected device corresponding to the shortcut is available, and determines that the device identifier corresponding to the obtained IP address is the same as the identifier of the connected device, it means that the connected device is still using the IP address. Therefore, the connecting device can send a network connection request to the connected device through the IP address of the connected device to establish a network connection with the connected device.
[0151] In the solution provided by the embodiment of the present application, the connecting device can first send a network connection request to the IP address of the connected device, and then determine whether the IP address is available based on the response of the network connection request. On the basis that the IP address is available, it can further determine whether the device currently using the IP address is the connected device. In the case that the device currently using the IP address is the connected device, a network connection request is sent to the connected device through the IP address of the connected device to establish a network connection with the connected device, thereby improving the accuracy of establishing the connection.
[0152] As an implementation manner of the embodiment of the present application, after establishing the connection with the connected end device, the method may further include:
[0153] Based on the IP address of the connected end device corresponding to the successfully established connection, the pre-stored IP address of the connected end device is updated.
[0154] In order to enable the subsequent connection process to quickly establish a connection with the connected device by launching a shortcut based on the IP address of the connected device corresponding to the shortcut, after the connecting device establishes a connection with the connected device, the connecting device can update the pre-stored IP address of the connected device based on the IP address of the connected device corresponding to the successfully established connection.
[0155] In one embodiment, when the connecting device establishes a network connection with the connected device based on the IP address returned by multicast, because the connected device will return the IP address to the connecting device when responding to the multicast, the connecting device can directly use the IP address returned by the multicast as the IP address of the connected device corresponding to the successfully established connection, and then update the pre-stored IP address of the connected device based on the IP address.
[0156] In another embodiment, when the connecting device establishes a wireless network connection with the connected device through a wireless network direct connection, because it is not necessary to obtain or use the IP address of the connected device during the establishment of the wireless network connection, the connecting device can send an identification acquisition request to the IP address of the connected device after establishing a wireless network connection with the connected device, so as to obtain the IP address of the connected device, and use it as the IP address of the connected device corresponding to the successfully established connection, and then update the pre-stored IP address of the connected device based on the IP address.
[0157] In the solution provided by the embodiment of the present application, after the connecting end device establishes a connection with the connected end device, the pre-stored IP address of the connected end device can be updated based on the IP address of the connected end device corresponding to the successfully established connection. Thus, the subsequent connection process can quickly establish a connection with the connected end device by starting the shortcut and based on the IP address of the connected end device corresponding to the shortcut.
[0158] As an implementation method of an embodiment of the present application, the connected device identifier can be generated based on the hardware serial number of the connected device, the initial MAC address of the connected device, or randomly generated. The connected device identifier is used to uniquely identify the connected device and is fixed.
[0159] In one embodiment, the above-mentioned connected device identifier can be a GUID (Globally Unique Identifier), and the GUID can be generated by directly using the hardware serial number or initial MAC address of the connected device as the GUID, or by adding a random number to the hardware serial number or initial MAC address of the connected device to generate the GUID, or by generating a random number and directly using the random number as the GUID, which is not specifically limited here.
[0160] Among them, in the method of generating a random number and directly using the random number as a GUID, in order to avoid generating the same random number, non-random parameters such as time can be added to the random number generation algorithm.
[0161] In the solution provided in the embodiment of the present application, the connected device identifier can be generated based on the hardware serial number of the connected device, the initial MAC address of the connected device, or randomly generated, so as to uniquely identify the connected device and remain unchanged. In this way, even if the IP address of the connected device changes, or the network card of the connected device is replaced, causing the MAC address of the connected device to change, because the device identifier is used to uniquely identify the connected device and remains unchanged, the connected device can be determined by the device identifier of the connected device, thereby allowing the connecting device to establish a connection with the connected device.
[0162] Below Figure 8 Taking this as an example, a device connection method provided by an embodiment of the present application is introduced:
[0163] When the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can first start the shortcut, and then execute step S801 to obtain the IP and GUID from the startup parameters, that is, obtain the IP address and the connected end device identifier of the connected end device. Then the connecting end device can execute step S802 to determine whether this IP can be connected to the network, that is, determine whether the IP address is available. If it can, the connecting end device can execute step S803 to further determine whether the device's GUID is consistent with the GUID in the startup parameters, that is, determine whether the device identifier corresponding to the obtained IP address is the same as the connected end device identifier in the startup parameters of the shortcut. If they are the same, a network connection request can be sent to the connected end device through the IP address of the connected end device to establish a network connection with the connected end device, and then step S804 can be executed to determine that the connection is successful.
[0164] If the judgment result of step S802 or step S803 is no, the connecting end device can execute step S806, multicast detection device, that is, obtain the identification of the device in the same network as the connecting end device through multicast detection as the alternative device identification, and then the connecting end device can execute step S807, filter whether the device exists through GUID, that is, determine whether there is a connected end device identification in the alternative device identification, if so, the IP address returned by the connected end device based on multicast can be obtained; through the IP address, a network connection request is sent to the connected end device to establish a network connection with the connected end device, and then step S804 can be executed to determine whether the connection is successful.
[0165] If it does not exist, the connecting end device can execute step S808 to determine whether it supports Wi-Fi Direct, that is, determine whether it has the Wi-Fi Direct function. If it does not support it, the connecting end device can execute step S812 to determine that the connection fails. If it supports it, it can execute step S809 to detect the device through Wi-Fi Direct, that is, through the wireless network direct connection method, detect and obtain the identification of the device that has enabled the wireless network direct connection function within the preset range of the connecting end device as the alternative device identification, and then execute step S810 to filter whether the device exists through GUID, that is, determine whether there is a connected end device identification in the alternative device identification. If it does not exist, execute step S812 to determine that the connection fails. If it exists, execute step S811 to establish a Wi-Fi Direct connection, that is, send a wireless network connection request to the connected end device through the wireless network direct connection method to establish a wireless network connection with the connected end device, and then execute step S804 to determine that the connection is successful.
[0166] After the connecting device successfully connects to the connected device through multicast or wireless network direct connection, because the IP address of the connected device has changed at this time, the connecting device can execute step S805 to update the shortcut startup parameters after the connection is successful, that is, based on the IP address of the connected device corresponding to the successfully established connection, update the IP address of the connected device corresponding to the pre-stored shortcut.
[0167] After executing step S805 to update the shortcut startup parameters or executing step S812 to determine that the connection fails, the device connection method ends.
[0168] In the solution provided by the embodiment of the present application, when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can obtain the IP address and the connected end device identifier of the connected end device corresponding to the pre-stored shortcut; and establish a connection with the connected end device based on the IP address and the connected end device identifier. Since the connecting end device can obtain the IP address and the connected end device identifier of the connected end device when it obtains the connection instruction for the shortcut corresponding to the connected end device, when the IP address of the connected end device does not change, the connecting end device can directly establish a connection with the connected end device based on the obtained IP address through the shortcut. When the IP address of the connected end device changes, the connecting end device can also establish a connection with the connected end device based on the obtained connected end device identifier, because the connected end device identifier will not change, so even if the MAC address of the connected end device changes, the connecting end device can also find the connected end device based on the fixed connected end device identifier, thereby establishing a connection, thereby improving the success rate of the connecting end device establishing a connection with the connected end device through the shortcut.
[0169] Corresponding to the above-mentioned device connection method, an embodiment of the present application further provides a device connection apparatus. The following is an introduction to a device connection apparatus provided in an embodiment of the present application.
[0170] like Fig. 9 As shown, a device connection device is applied to a connection end device, and the device includes:
[0171] The information acquisition module 910 is used to acquire the IP address and the connected end device identifier of the connected end device corresponding to the shortcut stored in advance when acquiring the connection instruction for the shortcut corresponding to the connected end device;
[0172] The connection establishing module 920 is used to establish a connection with the connected end device based on the IP address of the connected end device and the connected end device identifier.
[0173] In the solution provided by the embodiment of the present application, when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can obtain the IP address and the connected end device identifier corresponding to the pre-stored shortcut; and establish a connection with the connected end device based on the IP address and the connected end device identifier of the connected end device. Since when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can directly establish a connection with the connected end device based on the IP address and the connected end device identifier corresponding to the pre-stored shortcut, there is no need for the user to manually input parameters such as the IP address of the connected end device, thereby improving the efficiency of establishing a connection between the connecting end device and the connected end device.
[0174] As an implementation of the embodiment of the present application, the connection establishment module 920 may include:
[0175] A network connection request sending unit, used to send a network connection request to the IP address of the connected end device;
[0176] A first detection unit, configured to detect and obtain an alternative device identifier by a preset device detection method when the network connection with the connected end device via the IP address fails;
[0177] The connection establishing unit is used to send a connection request to the connected end device when the connected end device identifier exists in the candidate device identifier, so as to establish a connection with the connected end device.
[0178] As an implementation mode of an embodiment of the present application, the above-mentioned first detection unit can be specifically used to obtain the identification of a device in the same network as the connection end device through multicast detection as a candidate device identification; or, through a wireless network direct connection method, detect and obtain the identification of a device that enables the wireless network direct connection function within a preset range of the connection end device as a candidate device identification;
[0179] The above-mentioned connection establishment unit can be specifically used to obtain the IP address of the connected device based on the multicast return when the multicast detects the connected device identifier; send a network connection request to the connected device based on the IP address returned by the multicast through the connected device to establish a network connection with the connected device; or, when the wireless network direct connection detects the connected device identifier, send a wireless network connection request to the connected device through the wireless network direct connection method to establish a wireless network connection with the connected device.
[0180] As an implementation of the embodiment of the present application, the connection establishment module 920 may further include a second detection unit;
[0181] The above-mentioned second detection unit is used to, when multicast fails to detect the identifier of the connected device, detect and obtain the identifier of a device that has enabled the wireless network direct connection function within a preset range of the connecting device through a wireless network direct connection method as a substitute device identifier; or, when the wireless network direct connection fails to detect the identifier of the connected device, obtain the identifier of a device in the same network as the connecting device through multicast detection as a substitute device identifier.
[0182] As an implementation of the embodiment of the present application, the connection establishment module 920 may further include a connection status determination unit;
[0183] The connection status determination unit is used to determine that the network connection with the connected device has failed when it is determined that the IP address is unavailable based on the response to the network connection request; or to obtain a device identifier corresponding to the IP address when it is determined that the IP address is available based on the response to the network connection request, and determine that the network connection with the connected device has failed when the obtained device identifier is different from the connected device identifier.
[0184] As an implementation of the embodiment of the present application, the above device may further include:
[0185] The IP address updating module is used to update the pre-stored IP address of the connected end device corresponding to the shortcut based on the IP address of the connected end device corresponding to the successfully established connection after establishing a connection with the connected end device.
[0186] As an implementation method of an embodiment of the present application, the above-mentioned connected device identifier is generated based on the hardware serial number of the connected device, the initial MAC address of the connected device, or randomly generated, and the connected device identifier is used to uniquely identify the connected device and is fixed; and / or,
[0187] The connection establishment module 920 may be specifically configured to send a network connection request to the IP address of the connected end device; if it is determined that the IP address is available based on the response to the network connection request, obtain a device identifier corresponding to the IP address; if the obtained device identifier is the same as the connected end device identifier, send a network connection request to the connected end device via the IP address of the connected end device to establish a network connection; and / or,
[0188] The connecting end device may further store the port information of the connected end device corresponding to the shortcut, and the apparatus may further include a program connection module;
[0189] The program connection module is used to establish a connection with a target application installed in the connected end device based on the port information after the connection with the connected end device is established.
[0190] The present application also provides an electronic device, such as Fig.10 As shown, including:
[0191] Memory 1001, used for storing computer programs;
[0192] The processor 1002 is used to implement the device connection method described in any of the above embodiments when executing the program stored in the memory 1001.
[0193] In the solution provided by the embodiment of the present application, when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can obtain the IP address and the connected end device identifier corresponding to the pre-stored shortcut; and establish a connection with the connected end device based on the IP address and the connected end device identifier of the connected end device. Since when the connecting end device obtains the connection instruction for the shortcut corresponding to the connected end device, it can directly establish a connection with the connected end device based on the IP address and the connected end device identifier corresponding to the pre-stored shortcut, there is no need for the user to manually input parameters such as the IP address of the connected end device, thereby improving the efficiency of establishing a connection between the connecting end device and the connected end device.
[0194] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 1002, the communication interface, and the memory 1001 communicate with each other via the communication bus.
[0195] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0196] The communication interface is used for communication between the above electronic device and other devices.
[0197] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0198] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0199] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the device connection method described in any of the above embodiments is implemented.
[0200] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the device connection method described in any of the above embodiments.
[0201] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a solid-state hard disk (SSD), etc.
[0202] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0203] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, computer-readable storage medium, and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0204] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A device connection method, characterized in that: Applied to a connection end device, the method comprises: When a connection instruction for a shortcut corresponding to a connected end device is obtained, an IP address and an identifier of the connected end device corresponding to the shortcut stored in advance are obtained; A connection is established with the connected end device based on the IP address of the connected end device and the connected end device identifier.
2. The method according to claim 1, characterized in that The establishing a connection with the connected end device based on the IP address and the connected end device identifier of the connected end device includes: Sending a network connection request to the IP address of the connected end device; If the network connection with the connected end device fails through the IP address, the alternative device identification is obtained through the preset device detection method; If the connected-end device identifier exists in the candidate device identifiers, a connection request is sent to the connected-end device to establish a connection with the connected-end device.
3. The method according to claim 2, characterized in that The step of obtaining the candidate device identification by detecting in a preset device detection mode includes: Obtaining, by multicast detection, an identifier of a device in the same network as the connection end device as a candidate device identifier; or, by wireless network direct connection, detecting and obtaining, by wireless network direct connection, an identifier of a device with a wireless network direct connection function enabled within a preset range of the connection end device as a candidate device identifier; The sending a connection request to the connected end device to establish a connection with the connected end device includes: In the case where the multicast detects the connected end device identifier, obtaining the IP address of the connected end device based on the multicast return; sending a network connection request to the connected end device based on the IP address returned by the multicast, so as to establish a network connection with the connected end device; or, When the wireless network direct connection detects the connected end device identifier, a wireless network connection request is sent to the connected end device through the wireless network direct connection mode to establish a wireless network connection with the connected end device.
4. The method according to claim 3, characterized in that The method further comprises: In the case where the multicast fails to detect the identification of the connected end device, the identification of a device with the wireless network direct connection function enabled within a preset range of the connecting end device is detected by wireless network direct connection as a candidate device identification; or In the case that the wireless network direct connection fails to detect the identification of the connected end device, the identification of a device in the same network as the connecting end device is obtained through multicast detection as a candidate device identification.
5. The method according to any one of claims 2 to 4, characterized in that: Before the step of detecting and obtaining the candidate device identifier by a preset device detection method if the network connection with the connected end device by the IP address fails, the method further includes: In the case where it is determined that the IP address is unavailable based on the response to the network connection request, determining that the network connection with the connected end device fails; or, When it is determined that the IP address is available based on the response to the network connection request, a device identifier corresponding to the IP address is obtained. When the obtained device identifier is different from the connected device identifier, it is determined that the network connection with the connected device has failed.
6. The method according to any one of claims 1 to 4, characterized in that: After establishing the connection with the connected end device, the method further includes: Based on the IP address of the connected end device corresponding to the successfully established connection, the pre-stored IP address of the connected end device corresponding to the shortcut is updated.
7. The method according to any one of claims 1 to 4, characterized in that: The connected-end device identifier is generated based on the hardware serial number of the connected-end device, the initial MAC address of the connected-end device, or is randomly generated. The connected-end device identifier is used to uniquely identify the connected-end device and is fixed; and / or, The establishing a connection with the connected end device based on the IP address and the connected end device identifier of the connected end device includes: Sending a network connection request to the IP address of the connected end device; In the case where it is determined that the IP address is available based on the response to the network connection request, obtaining a device identifier corresponding to the IP address, and if the obtained device identifier is the same as the identifier of the connected device, sending a network connection request to the connected device via the IP address of the connected device to establish a network connection with the connected device; and / or, The connecting end device also stores the port information of the connected end device corresponding to the shortcut. After establishing the connection with the connected end device, the method further includes: A connection is established with a target application installed in the connected end device based on the port information.
8. A device connection device, characterized in that: Applied to a connection terminal device, the device comprises: An information acquisition module, configured to acquire, when a connection instruction for a shortcut corresponding to a connected end device is acquired, an IP address of the connected end device and a connected end device identifier corresponding to the shortcut stored in advance; The connection establishment module is used to establish a connection with the connected end device based on the IP address of the connected end device and the connected end device identifier.
9. The device according to claim 8, characterized in that The connection establishment module comprises: A network connection request sending unit, used to send a network connection request to the IP address of the connected end device; A first detection unit, configured to detect and obtain an alternative device identifier by a preset device detection method when the network connection with the connected end device via the IP address fails; a connection establishing unit, configured to send a connection request to the connected end device to establish a connection with the connected end device when the connected end device identifier exists in the candidate device identifier; or The first detection unit is specifically used to obtain, through multicast detection, an identifier of a device in the same network as the connection end device as a candidate device identifier; or, through a wireless network direct connection method, to detect and obtain, as a candidate device identifier, an identifier of a device that has a wireless network direct connection function enabled within a preset range of the connection end device; The connection establishment unit is specifically used to obtain the IP address of the connected end device based on the multicast return when the multicast detects the connected end device identifier; send a network connection request to the connected end device based on the IP address returned by the multicast through the connected end device to establish a network connection with the connected end device; or, when the wireless network direct connection detects the connected end device identifier, send a wireless network connection request to the connected end device through the wireless network direct connection method to establish a wireless network connection with the connected end device; or, The connection establishment module also includes a second detection unit; The second detection unit is used to detect the identification of a device that enables the wireless network direct connection function within a preset range of the connecting end device through a wireless network direct connection method when the multicast fails to detect the identification of the connected end device, as a candidate device identification; or, when the wireless network direct connection fails to detect the identification of the connected end device, obtain the identification of a device in the same network as the connecting end device through multicast detection as a candidate device identification; or, The connection establishment module also includes a connection status determination unit; The connection status determination unit is used to determine that the network connection with the connected end device has failed when it is determined that the IP address is unavailable based on the response to the network connection request; or, when it is determined that the IP address is available based on the response to the network connection request, obtain a device identifier corresponding to the IP address, and when the obtained device identifier is different from the connected end device identifier, determine that the network connection with the connected end device has failed; or, The device also includes: An IP address updating module is used to update the pre-stored IP address of the connected end device corresponding to the shortcut after establishing a connection with the connected end device based on the IP address of the connected end device corresponding to the successfully established connection; or, The connected device identifier is generated based on the hardware serial number of the connected device, the initial MAC address of the connected device, or is randomly generated. The connected device identifier is used to uniquely identify the connected device and is fixed; and / or, The connection establishment module is specifically configured to send a network connection request to the IP address of the connected end device; if it is determined that the IP address is available based on the response to the network connection request, obtain a device identifier corresponding to the IP address; if the obtained device identifier is the same as the connected end device identifier, send a network connection request to the connected end device through the IP address of the connected end device to establish a network connection; and / or, The connecting end device also stores the port information of the connected end device corresponding to the shortcut, and the apparatus further comprises a program connection module; The program connection module is used to establish a connection with a target application installed in the connected end device based on the port information after the connection with the connected end device is established.
10. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, for implementing any of the methods described in claims 1-7 when executing a program stored in a memory.
Citation Information
Patent Citations
Server connection method, electronic equipment, system and medium
CN110417789A
Network connection method and apparatus, and electronic device
CN115776711A
Communication Device
US20180248697A1