Network connection method, terminal and computer readable storage medium
By implementing the method of dynamically adjusting network priorities on the terminal, the problem that network equipment cannot switch intelligently and automatically in the prior art is solved, ensuring that the optimal access method is selected under different network conditions, and network reliability and user experience are improved.
Patent Information
- Application Number
- CN202411568585.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-03-25
AI Technical Summary
Existing network equipment cannot achieve intelligent automatic switching in the event of network failure, resulting in users experiencing long interrupt times and poor network performance during network failure.
By implementing the method of dynamically adjusting network priority on the terminal, when the wired network is unavailable, try to access the preset network address. If it is not successful, temporarily adjust the priority, switch to the wireless network for connection, and restore the default priority when the wired network is restored to be available.
Ensure that the optimal network access method is always selected under different network conditions, improve network reliability and user experience, and reduce network interruption time.
Smart Images

Figure CN119697672A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of network technology, and in particular, to a network connection method, a terminal, and a computer-readable storage medium. Background Art
[0002] In the prior art, network devices usually have multiple connection methods, such as Ethernet and mobile networks. However, these devices often fail to implement intelligent automatic switching mechanisms when connecting. When the primary Ethernet connection fails, the device usually does not automatically switch to the backup mobile network, but relies on static fault detection methods. This defect makes it impossible for the device to respond to changes in network status in real time, resulting in users experiencing longer interruptions and poor network performance during network failures.
[0003] Although the device can support multiple connection modes, due to the lack of flexible automatic switching function, users still need to intervene manually, which increases the complexity and delay of troubleshooting. This phenomenon significantly affects the reliability of the network and user experience. Therefore, the existing technology has obvious deficiencies in intelligent management and dynamic switching capabilities. Summary of the invention
[0004] The embodiments of the present application provide a network connection method, a terminal, and a computer-readable storage medium, which can always select the optimal network access method under different network conditions to ensure that users can always obtain a stable connection experience.
[0005] A first aspect of an embodiment of the present application provides a network connection method, the method comprising:
[0006] When the terminal is powered on, a network connection is performed through a wired network based on a default priority order of a wired network and a wireless network, wherein the priority of the wired network is higher than the priority of the wireless network by default;
[0007] Preliminarily determining whether the wired network is available according to the data transmission and data reception conditions of the wired network;
[0008] If it is preliminarily determined that the wired network is unavailable, attempting to access a preset network address through the wired network;
[0009] If it is determined that the preset network address is not successfully accessed, the priority order of the wired network and the wireless network is temporarily adjusted, and the network connection is performed through the wireless network.
[0010] Optionally, after establishing a network connection through the wireless network, the method further includes:
[0011] Detecting whether the wired network is restored to be available;
[0012] If it is determined that the wired network is restored to be available, the default priority order of the wired network and the wireless network is restored, and the network connection is performed through the wired network.
[0013] Optionally, the detecting whether the wired network is restored to be available includes:
[0014] Determine the time of diagnosis;
[0015] Diagnosing the wired network at the diagnosis time and obtaining a diagnosis result;
[0016] Whether the wired network is restored to availability is determined based on the diagnosis result.
[0017] Optionally, judging whether the wired network is restored to be available according to the diagnosis result includes:
[0018] Determine whether there are M consecutive times in the diagnosis result that the network is available;
[0019] If so, it is determined that the wired network is restored and available; if not, it is determined that the wired network is not restored and available.
[0020] Optionally, judging whether the wired network is restored to be available according to the diagnosis result includes:
[0021] Determine whether the number of times the network is available in the diagnosis result is on an upward trend, and whether the probability of the network being available in the most recent N times reaches a preset threshold;
[0022] If so, it is determined that the wired network is restored and available; if not, it is determined that the wired network is not restored and available.
[0023] Optionally, preliminarily determining whether the wired network is available according to data sending and data receiving conditions of the wired network includes:
[0024] Monitoring the number of bytes received and sent by the wired network within a preset time;
[0025] Whether the wired network is available is preliminarily determined based on the number of received and sent bytes.
[0026] Optionally, if it is determined that the preset network address is not successfully accessed, after the network connection is established through the wireless network, the method further includes:
[0027] Generate wired network exception reports;
[0028] The wired network abnormality report is sent to a server.
[0029] A second aspect of an embodiment of the present application provides a device, including:
[0030] A first connection unit, configured to connect to a network through a wired network based on a default priority order of the wired network and the wireless network when the terminal is powered on, wherein the priority of the wired network is higher than that of the wireless network by default;
[0031] A determination unit, configured to preliminarily determine whether the wired network is available according to data transmission and data reception conditions of the wired network;
[0032] an access unit, configured to attempt to access a preset network address through the wired network if it is preliminarily determined that the wired network is unavailable;
[0033] The second connection unit is used to temporarily adjust the priority order of the wired network and the wireless network and perform network connection through the wireless network if it is determined that the preset network address has not been successfully accessed.
[0034] Optionally, the device further includes:
[0035] A detection unit, used to detect whether the wired network is restored to be available;
[0036] The third connection unit is used to restore the default priority order of the wired network and the wireless network if it is determined that the wired network is restored to be available, and to perform network connection through the wired network.
[0037] Optionally, the detection unit includes:
[0038] A determination module, used for determining a diagnosis time;
[0039] A diagnosis module, used to diagnose the wired network at the diagnosis time and obtain a diagnosis result;
[0040] A judgment module is used to judge whether the wired network is restored to be available according to the diagnosis result.
[0041] Optionally, the judgment module is specifically used for:
[0042] Determine whether there are M consecutive times in the diagnosis result that the network is available;
[0043] If so, it is determined that the wired network is restored and available; if not, it is determined that the wired network is not restored and available.
[0044] Optionally, the judgment module is specifically used for:
[0045] Determine whether the number of times the network is available in the diagnosis result is on an upward trend, and whether the probability of the network being available in the most recent N times reaches a preset threshold;
[0046] If so, it is determined that the wired network is restored and available; if not, it is determined that the wired network is not restored and available.
[0047] Optionally, the determining unit is specifically configured to:
[0048] Monitoring the number of bytes received and sent by the wired network within a preset time;
[0049] Whether the wired network is available is preliminarily determined based on the number of received and sent bytes.
[0050] Optionally, the device further comprises a reporting unit, wherein the reporting unit is configured to:
[0051] Generate wired network exception reports;
[0052] The wired network abnormality report is sent to a server.
[0053] A third aspect of an embodiment of the present application provides a terminal, including:
[0054] Processor, memory, input-output unit, and bus;
[0055] The processor is connected to the memory, the input and output unit, and the bus;
[0056] A program is stored in the memory, and the processor calls the program to execute the method in the first aspect and any possible implementation manner of the first aspect.
[0057] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the computer executes the method in the first aspect and any possible implementation of the first aspect.
[0058] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:
[0059] In an embodiment of the present application, when the terminal is turned on, it preferentially connects to the wired network to establish a network connection. Then, the terminal monitors the sending and receiving of data to determine the availability of the wired network. If it is preliminarily determined that the wired network is unavailable, the terminal will try to access the preset network address to further confirm the connection status. If the access is unsuccessful, the terminal will temporarily adjust the network priority and switch to the wireless network for connection. By preferentially connecting to the wired network and flexibly adjusting the network priority when necessary, the terminal can always maintain the best network access method under different network conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 A flowchart of an embodiment of a network connection method in an embodiment of the present application;
[0061] Figure 2A flowchart of an embodiment of detecting whether it is necessary to restore the default priority order of wired networks and wireless networks in an embodiment of the present application;
[0062] Figure 3 A schematic diagram of a flow chart of an embodiment of detecting whether a wired network is restored and available in an embodiment of the present application;
[0063] Figure 4 A flowchart of an embodiment of determining whether a wired network is restored and available according to a diagnosis result in an embodiment of the present application;
[0064] Figure 5 A flowchart of another embodiment of determining whether a wired network is restored and available according to a diagnosis result in an embodiment of the present application;
[0065] Figure 6 A schematic diagram of a flow chart of an embodiment of generating a wired network abnormality report in an embodiment of the present application;
[0066] Figure 7 This is a schematic diagram of the structure of an embodiment of a terminal in the embodiments of the present application;
[0067] Figure 8 This is a schematic diagram of the structure of another embodiment of the terminal in the embodiments of the present application. DETAILED DESCRIPTION
[0068] The embodiments of the present application provide a network connection method, a terminal, and a computer-readable storage medium for always selecting an optimal network access method under different network conditions.
[0069] The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0070] See also Figure 1 In the embodiment of the present application, one embodiment of the network connection method includes:
[0071] 101. When the terminal is powered on, a network connection is made through a wired network based on the default priority order of the wired network and the wireless network, wherein the priority of the wired network is higher than the priority of the wireless network by default;
[0072] When the terminal starts, it will first identify the network interface and select a network connection according to the preset priority order. Wired networks are usually set to take precedence over wireless networks, which means that when both wired and wireless connections are available, the terminal will give priority to wired connections. This selection mechanism ensures a more stable network connection because wired networks are usually better than wireless networks in terms of signal stability and speed.
[0073] 102. Preliminarily determine whether the wired network is available based on the data transmission and data reception status of the wired network;
[0074] After connecting to the wired network, the terminal will monitor the sending and receiving of data. The key to this step is to evaluate the effectiveness of the network. By monitoring the network traffic, the terminal can determine whether the connection is normal. If data can be successfully sent and received, it means that the wired network is available; otherwise, there may be a connection problem.
[0075] Specifically, when initially determining the availability of the wired network, the terminal will monitor the number of bytes received and sent within a preset time. This process involves real-time tracking of network traffic and recording the amount of data transmitted by the wired network during that time period. By analyzing these byte counts, the terminal can obtain important information about network performance.
[0076] Once the number of received and sent bytes is obtained, the terminal will perform a preliminary analysis based on this data to determine whether the wired network is available. Specifically, if the number of received and sent bytes exceeds the preset threshold, the terminal will consider the wired network to be available; if the number of bytes does not reach the threshold, the terminal will determine that the wired network is unavailable. This preliminary judgment provides a basis for subsequent network access.
[0077] In one possible example, the terminal monitors the number of bytes received and sent within a period of time (this period of time can be set manually, such as 2 minutes or other time). If only bytes are sent but no bytes are received, a preliminary diagnostic result indicating that the network is unavailable can be generated.
[0078] 103. If it is preliminarily determined that the wired network is unavailable, then try to access the preset network address through the wired network;
[0079] When the wired network is initially determined to be unavailable, the terminal will attempt to access a preset network address through the wired network. This attempt is to further confirm the connection status. If the access is successful, it means that the wired network may have intermittent problems, rather than being completely unavailable.
[0080] 104. If it is determined that the preset network address is not successfully accessed, the priority order of the wired network and the wireless network is temporarily adjusted, and the network connection is performed through the wireless network.
[0081] If the terminal fails to access the preset address after trying, it will temporarily adjust the network priority, lower the priority of the wired network and increase the priority of the wireless network. In this way, the terminal will establish a connection through the wireless network to ensure continuous network access. This dynamic adjustment strategy effectively improves the network availability of the terminal and avoids network interruptions caused by wired network failures.
[0082] In this embodiment, when the terminal is turned on, it preferentially connects to the wired network to establish a network connection. Then, the terminal monitors the sending and receiving of data to determine the availability of the wired network. If it is initially determined that the wired network is unavailable, the terminal will try to access the preset network address to further confirm the connection status. If the access is unsuccessful, the terminal will temporarily adjust the network priority and switch to the wireless network for connection. By preferentially connecting to the wired network and flexibly adjusting the network priority when necessary, the terminal can always maintain the best network access method under different network conditions.
[0083] See also Figure 2 In some embodiments of the present application, after the step 104 in the above embodiment connects to the network through the wireless network, the following steps 201 to 202 may be further included:
[0084] 201. Detect whether the wired network is restored and available;
[0085] The terminal will periodically check the status of the wired network to confirm whether it has been restored. This detection process may involve monitoring indicators such as network signal strength and data transmission rate. If the wired network is restored, the terminal will prepare for subsequent connections.
[0086] 202. If it is determined that the wired network is restored to be available, the default priority order of the wired network and the wireless network is restored, and the network connection is performed through the wired network.
[0087] After confirming that the wired network is available again, the terminal will reset the network priority and raise the priority of the wired network to the default state. This means that the terminal will give priority to connecting through the wired network to take advantage of its stability and speed. This operation ensures that the terminal always uses the best network connection when conditions permit.
[0088] In this embodiment, during the process of detecting and restoring the wired network, the terminal can effectively adapt to changes in the network environment, thereby improving the reliability and performance of the overall network. Ultimately, the terminal can always select the optimal network access method under different network conditions.
[0089] See also Figure 3 In some embodiments of the present application, step 201 in the above embodiment of detecting whether the wired network is restored to be available may include the following steps 301 to 303:
[0090] 301. Determine the time of diagnosis;
[0091] Before performing network diagnosis, the terminal needs to set a time period as the execution time of the diagnosis. This time period can be determined according to a fixed diagnosis cycle or can be adjusted dynamically, and does not have to be a fixed time interval. For example, the diagnosis time can be adjusted according to the results of the previous diagnosis and the changes in the network status, so that the next diagnosis can be performed at the most appropriate time to ensure real-time and accuracy.
[0092] 302. Diagnose the wired network at the diagnosis time and obtain the diagnosis result;
[0093] Within the preset diagnostic time range, the terminal will continuously diagnose the wired network. This process includes real-time monitoring of the stability of the network connection, data transmission rate and other key indicators. Each diagnosis will generate a preset number of diagnostic results, providing important data support for subsequent judgments.
[0094] 303. Determine whether the wired network is restored and available based on the diagnosis result.
[0095] After obtaining the diagnostic results, the terminal will analyze the data to determine whether the wired network has been restored. If the results show that the wired network has been restored, the terminal can re-include it as a priority connection option. This judgment process ensures that the network status is updated in a timely manner, providing a basis for subsequent connection strategies.
[0096] In this embodiment, the terminal can continuously evaluate the status of the wired network and quickly adjust the network access mode after it is restored, thereby ensuring the stability and reliability of the connection. Ultimately, the terminal can always select the optimal network access mode under different network conditions.
[0097] See also Figure 4 In some embodiments of the present application, step 303 in the above embodiment determines whether the wired network is restored and available according to the diagnosis result, and may include the following steps 401 to 403:
[0098] 401. Determine whether the diagnosis result indicates that the network is available for M consecutive times; if yes, execute step 402; if no, execute step 403.
[0099] The terminal analyzes the diagnostic results to determine whether there are M consecutive times within the time range of the diagnostic time that the network is available. This judgment usually involves statistics and comparison of the diagnostic results obtained during this diagnostic time to determine the stability and availability of the network. If M consecutive diagnostic results show that the network is available, it indicates that the network connection has returned to normal, and the terminal can consider switching back to wired network access. If the result does not meet this condition, it may indicate that the network problem has not been resolved and the terminal needs to maintain the current access method.
[0100] 402. Determine that the wired network is restored and available;
[0101] After determining that the conditions that indicate network availability are met for M consecutive times, the terminal will determine the switching conditions. This means that the device will consider switching the network access mode from wireless network back to wired network access. This step involves a comprehensive evaluation of the current network status, including parameters such as network latency, bandwidth utilization, and data loss rate, to ensure the rationality and necessity of the switch.
[0102] 403. It is determined that the wired network has not been restored.
[0103] If the judgment result shows that the condition that the network is available for M consecutive times is not met, the terminal will perform a confirmation that the wired network has not been restored. In this case, the terminal needs to continue to use the current network access method and maintain continuous monitoring of the network. The confirmation that the wired network has not been restored ensures that the terminal will not switch in an unstable network environment, thereby avoiding possible network failures and a decrease in user experience.
[0104] In this embodiment, the terminal can effectively judge and process the availability of the network connection, thereby ensuring the stability of the network. After the availability is confirmed for M consecutive times, the terminal can switch to a more optimal network access method in a timely manner to ensure the smoothness of the user experience. At the same time, the judgment of whether the wired network is restored to be available ensures the stability and reliability of the terminal in the case of network abnormalities, reduces unnecessary network switching operations, and improves the intelligent level of network management.
[0105] See also Figure 5 In some embodiments of the present application, step 303 in the above embodiment determines whether the wired network is restored and available according to the diagnosis result, and may include the following steps 501 to 503:
[0106] 501. Determine whether the number of times the network is available in the diagnosis result is on an upward trend, and whether the probability of the network being available in the last N times reaches a preset threshold; if so, execute step 502; if not, execute step 503;
[0107] The terminal analyzes the diagnostic results to determine whether the number of times the network is available shows an upward trend within the set diagnostic time. This judgment involves statistical analysis of the diagnostic results obtained during this diagnostic time to identify whether there is a pattern of continuous increase. At the same time, the terminal also needs to check whether the probability of the network being available in the most recent N diagnostic results reaches a preset threshold. If both conditions are met, it indicates that the network connection status continues to improve, and the terminal can consider network switching; if not, it may mean that the network is still unstable and the terminal needs to maintain the current access method.
[0108] 502. Determine that the wired network is restored and available;
[0109] After confirming that the number of availability times in the continuous diagnosis results is on an upward trend and the probability of availability in the last N times meets the preset threshold, the terminal will determine that the wired network has recovered. This means that the terminal can safely switch the network access method from the current connection to a better network access method, such as switching from a wireless network back to a wired network access. This step involves a comprehensive evaluation of the current network performance to ensure the rationality of the switching operation to provide a better network experience for users.
[0110] 503. Determine that the wired network has not been restored to availability.
[0111] If the judgment result shows that the number of times characterized as network availability is not met or the probability of availability in the last N times does not reach the preset threshold, the terminal can determine that the wired network has not yet been restored. At this time, the terminal needs to continue to maintain the current network access method and keep monitoring the network status. Confirming whether the wired network is restored can avoid switching in an unstable network environment, thereby reducing the risk of potential network failures and ensuring that the user experience is not affected.
[0112] In this embodiment, the terminal can efficiently determine and manage the availability of the network connection. The analysis of the diagnostic results ensures that the terminal switches in a stable network environment, improving the user's network experience. At the same time, the confirmation mechanism for the recovery of the wired network effectively reduces the risk of network failure, enhances the reliability and intelligence level of the terminal, and promotes the refinement of network management.
[0113] See also Figure 6 In some embodiments of the present application, if it is determined that the preset network address is not successfully accessed, after the network connection is performed through the wireless network in step 104 in the above embodiment, the network connection method may further include the following steps 601 to 602:
[0114] 601. Generate a wired network abnormality report;
[0115] After confirming that the preset network address has not been successfully accessed, the terminal will generate a wired network exception report. The report will record in detail the reason for the network connection failure, the detected error information and the relevant network status for subsequent analysis and troubleshooting. The purpose of generating an exception report is to solve potential network problems and provide necessary information support.
[0116] 602. Send a wired network abnormality report to the server.
[0117] Next, the terminal will send the generated wired network anomaly report to the server. This operation ensures that the relevant technical support team obtains network anomaly information in a timely manner for more in-depth analysis and repair. By feeding data back to the server, the terminal can help optimize network performance and reduce possible problems in the future.
[0118] In this embodiment, the terminal can not only record network abnormalities in a timely manner, but also feed back information to relevant teams, thereby facilitating problem resolution. This further enhances the terminal's fault handling capabilities and network management efficiency, ensuring that the optimal network access method can be continuously selected under different network conditions.
[0119] See also Figure 7 In the embodiments of the present application, one embodiment of the terminal includes:
[0120] The first connection unit 701 is used to connect to the network through the wired network based on the default priority order of the wired network and the wireless network when the terminal is powered on, wherein the priority of the wired network is higher than the priority of the wireless network by default;
[0121] The determination unit 702 is used to preliminarily determine whether the wired network is available according to the data transmission and data reception conditions of the wired network;
[0122] The access unit 703 is used to try to access the preset network address through the wired network if it is initially determined that the wired network is unavailable;
[0123] The second connecting unit 704 is configured to temporarily adjust the priority order of the wired network and the wireless network and perform network connection via the wireless network if it is determined that the preset network address has not been successfully accessed.
[0124] In this embodiment, when the terminal is turned on, the first connection unit 701 preferentially connects to the wired network to establish a network connection. Next, the determination unit 702 monitors the sending and receiving of data to determine the availability of the wired network. If it is preliminarily determined that the wired network is unavailable, the access unit 703 will attempt to access the preset network address to further confirm the connection status. If the access is unsuccessful, the second connection unit 704 will temporarily adjust the network priority and switch to the wireless network for connection. By preferentially connecting to the wired network and flexibly adjusting the network priority when necessary, the terminal can always maintain the best network access method under different network conditions.
[0125] Optionally, the device also includes:
[0126] A detection unit, used to detect whether the wired network is restored and available;
[0127] The third connection unit is used to restore the default priority order of the wired network and the wireless network if it is determined that the wired network is restored to be available, and to perform network connection through the wired network.
[0128] Optionally, the detection unit comprises:
[0129] A determination module, used for determining a diagnosis time;
[0130] The diagnosis module is used to diagnose the wired network at the diagnosis time and obtain the diagnosis result;
[0131] The judgment module is used to judge whether the wired network is restored and available according to the diagnosis result.
[0132] Optionally, the judgment module is specifically used for:
[0133] Determine whether there are M consecutive times in the diagnosis results that the network is available;
[0134] If so, it is determined that the wired network is restored and available; if not, it is determined that the wired network is not restored and available.
[0135] Optionally, the judgment module is specifically used for:
[0136] Determine whether the number of times the network is available in the diagnosis result is on an upward trend, and whether the probability of the network being available in the last N times reaches a preset threshold;
[0137] If so, it is determined that the wired network is restored and available; if not, it is determined that the wired network is not restored and available.
[0138] Optionally, the determining unit 702 is specifically configured to:
[0139] Monitor the number of bytes received and sent on the wired network within a preset time;
[0140] Preliminary determination of whether the wired network is available is made based on the number of bytes received and sent.
[0141] Optionally, the device further comprises a reporting unit, and the reporting unit is used for:
[0142] Generate wired network exception reports;
[0143] Send wired network exception report to the server.
[0144] In this implementation, the functions of each unit and module are the same as those described above. Figures 1 to 6 The steps in the illustrated embodiments correspond to each other and will not be described again here.
[0145] See also Figure 8 , another embodiment of the terminal in the embodiment of the present application includes:
[0146] Processor 801, memory 802, input and output unit 803 and bus 804;
[0147] The processor 801 is connected to the memory 802, the input and output unit 803 and the bus 804;
[0148] The memory 802 stores a program, and the processor 801 calls the program to execute Figures 1 to 6 Steps in the illustrated embodiment.
[0149] In this embodiment, the function of the processor 801 is the same as that of the aforementioned Figures 1 to 6 The steps in the illustrated embodiments correspond to each other and will not be described again here.
[0150] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0151] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0152] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0153] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0154] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A network connection method, characterized in that: include: When the terminal is powered on, a network connection is performed through a wired network based on a default priority order of a wired network and a wireless network, wherein the priority of the wired network is higher than the priority of the wireless network by default; Preliminarily determining whether the wired network is available according to the data transmission and data reception conditions of the wired network; If it is preliminarily determined that the wired network is unavailable, attempting to access a preset network address through the wired network; If it is determined that the preset network address is not successfully accessed, the priority order of the wired network and the wireless network is temporarily adjusted, and the network connection is performed through the wireless network.
2. The method according to claim 1, characterized in that: After the network connection is established through the wireless network, the method further includes: Detecting whether the wired network is restored to be available; If it is determined that the wired network is restored to be available, the default priority order of the wired network and the wireless network is restored, and the network connection is performed through the wired network.
3. The method according to claim 2, characterized in that The detecting whether the wired network is restored to be available comprises: Determine the time of diagnosis; Diagnosing the wired network at the diagnosis time and obtaining a diagnosis result; Whether the wired network is restored to availability is determined based on the diagnosis result.
4. The method according to claim 3, characterized in that: The determining, according to the diagnosis result, whether the wired network is restored to be available comprises: Determine whether there are M consecutive times in the diagnosis result that the network is available; If so, it is determined that the wired network is restored and available; if not, it is determined that the wired network is not restored and available.
5. The method according to claim 3, characterized in that: The determining, according to the diagnosis result, whether the wired network is restored to be available comprises: Determine whether the number of times the network is available in the diagnosis result is on an upward trend, and whether the probability of the network being available in the most recent N times reaches a preset threshold; If so, it is determined that the wired network is restored and available; if not, it is determined that the wired network is not restored and available.
6. The method according to any one of claims 1 to 5, characterized in that The preliminarily determining whether the wired network is available according to the data transmission and data reception conditions of the wired network includes: Monitoring the number of bytes received and sent by the wired network within a preset time; Whether the wired network is available is preliminarily determined based on the number of received and sent bytes.
7. The method according to any one of claims 1 to 5, characterized in that If it is determined that the preset network address is not successfully accessed, after the network connection is established through the wireless network, the method further includes: Generate wired network exception reports; The wired network abnormality report is sent to a server.
8. A terminal, characterized in that: include: A first connection unit, configured to connect to a network through a wired network based on a default priority order of the wired network and the wireless network when the terminal is powered on, wherein the priority of the wired network is higher than that of the wireless network by default; A determination unit, configured to preliminarily determine whether the wired network is available according to data transmission and data reception conditions of the wired network; an access unit, configured to attempt to access a preset network address through the wired network if it is preliminarily determined that the wired network is unavailable; The second connection unit is used to temporarily adjust the priority order of the wired network and the wireless network if it is determined that the preset network address has not been successfully accessed, and to perform network connection through the wireless network.
9. A terminal, characterized in that: include: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; A program is stored in the memory, and the processor calls the program to execute the method according to any one of claims 1 to 7. 10 . A computer-readable storage medium having a program stored thereon, wherein when the program is executed on a computer, the computer is caused to execute the method according to claim 1 .