Method, apparatus, readable medium and electronic device for connecting wireless network

By obtaining the terminal's historical network connection information, it can be determined whether the target response message has been used to connect to the wireless network, thus solving the problem of terminals using incorrect IP addresses in a multi-DHCP server environment and achieving a higher wireless network connection success rate.

CN115643628BActive Publication Date: 2025-12-30BEIJING YOUZHUJU NETWORK TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210822691.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-12
Publication Date
2025-12-30
Estimated Expiration
2042-07-12

AI Technical Summary

Technical Problem

In a network environment with multiple DHCP servers, a terminal may use an incorrect IP address, resulting in the inability to access the internet.

Method used

By obtaining the terminal's historical network connection information, it can be determined whether the target response message has been used to connect to the wireless network. If not, the target response message sent by different DHCP servers can be used to connect to the wireless network.

Benefits of technology

It improves the success rate of wireless network connections and reduces the probability of encountering problems with internet access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115643628B_ABST
    Figure CN115643628B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, device, readable medium and electronic device for connecting a wireless network, wherein a terminal can receive a target response message sent by a target dynamic host configuration protocol (DHCP) server in response to a DHCP discovery message sent by the terminal, obtain historical networking information recorded by the terminal, determine whether the terminal has connected a current target wireless network using the target response message according to the historical networking information when it is determined that a plurality of first response messages are recorded in the historical networking information and that the terminal last connected the target wireless network abnormally according to the historical networking information, and connect the target wireless network according to the target response message when it is determined that the terminal has not connected the target wireless network using the target response message.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of wireless network connectivity, and more specifically, to a method, apparatus, readable medium, and electronic device for connecting to a wireless network. Background Technology

[0002] In a network environment, devices seeking to connect to the internet need to obtain network parameters such as IP addresses before connecting. DHCP (Dynamic Host Configuration Protocol) servers can automatically assign IP addresses to devices, solving various problems associated with manually configuring IP addresses. However, with the continuous development of network devices, network environments are becoming increasingly complex. A single network environment may have multiple DHCP servers assigning IP addresses to user devices, potentially causing these devices to be unable to access the internet. Summary of the Invention

[0003] This summary section is provided to briefly introduce the concepts, which will be described in detail in the detailed description section below. This summary section is not intended to identify key or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0004] In a first aspect, this disclosure provides a method for connecting to a wireless network, the method comprising:

[0005] After sending a Dynamic Host Configuration Protocol (DHCP) Discover message, receive a target response message sent by the target DHCP server in response to the DHCP Discover message;

[0006] Obtain historical network connection information recorded by the terminal;

[0007] If it is determined that multiple first response messages are recorded in the historical network information, and it is determined that the terminal's last wireless network connection was abnormal based on the historical network information, then it is determined whether the terminal has used the target response message to connect to the current target wireless network based on the historical network information, and different DHCP servers send different first response messages to the terminal.

[0008] If it is determined that the terminal has not used the target response message to connect to the target wireless network, then the terminal connects to the target wireless network according to the target response message.

[0009] Secondly, this disclosure provides an apparatus for connecting to a wireless network, the apparatus comprising:

[0010] The receiving module is used to receive a target response message sent by the target DHCP server in response to the DHCP discovery message after sending a Dynamic Host Configuration Protocol (DHCP) discovery message;

[0011] The acquisition module is used to acquire historical network connection information recorded by the terminal.

[0012] The determination module is used to determine whether the terminal has used the target response message to connect to the current target wireless network when it is determined that there are multiple first response messages recorded in the historical network information and the terminal's last wireless network connection was abnormal according to the historical network information. Different DHCP servers send different first response messages to the terminal.

[0013] A connection module is configured to connect to the target wireless network based on the target response message when it is determined that the terminal has not used the target response message to connect to the target wireless network.

[0014] Thirdly, this disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect of this disclosure.

[0015] Fourthly, this disclosure provides an electronic device, comprising:

[0016] A storage device on which computer programs are stored;

[0017] A processing device for executing the computer program in the storage device to implement the steps of the method described in the first aspect of this disclosure.

[0018] Through the above technical solution, after sending a Dynamic Host Configuration Protocol (DHCP) Discover message, a target response message is received from the target DHCP server in response to the DHCP Discover message; historical network information recorded when the terminal last connected to the wireless network is obtained; if it is determined that multiple first response messages are recorded in the historical network information, and it is determined based on the historical network information that the terminal's last wireless network connection was abnormal, it is determined based on the historical network information whether the terminal has used the target response message to connect to the current target wireless network, and different DHCP servers send different first response messages to the terminal; if it is determined that the terminal has not used the target response message to connect to the target wireless network, it connects to the target wireless network according to the target response message. Since different DHCP servers send different first response messages to the terminal, if it is determined that there are multiple first response messages recorded in the historical network information, it can be determined that there are multiple DHCP servers in the current wireless network environment corresponding to the terminal. In order to avoid the terminal using the wrong IP address to connect to the wireless network in a network environment with multiple DHCP servers, it is possible to connect to the current target wireless network according to the target response message after confirming that the terminal has not used the target response message to connect to the target wireless network. This can improve the success rate of wireless network connection and reduce the probability of the inability to access the Internet.

[0019] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description

[0020] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale. In the drawings:

[0021] Figure 1 This is an existing DHCP flowchart;

[0022] Figure 2 This is a flowchart illustrating a method for connecting to a wireless network according to an exemplary embodiment;

[0023] Figure 3 This is a flowchart illustrating a method for connecting to a wireless network according to an exemplary embodiment;

[0024] Figure 4 This is a flowchart illustrating a method for connecting to a wireless network according to an exemplary embodiment;

[0025] Figure 5 This is a block diagram illustrating an apparatus for connecting to a wireless network according to an exemplary embodiment;

[0026] Figure 6 This is a block diagram illustrating an apparatus for connecting to a wireless network according to an exemplary embodiment;

[0027] Figure 7 This is a structural block diagram of an electronic device according to an exemplary embodiment. Detailed Implementation

[0028] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0029] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0030] The term "comprising" and its variations as used herein are open-ended inclusions, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below.

[0031] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0032] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0033] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0034] It is understood that before using the technical solutions disclosed in the various embodiments of this disclosure, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.

[0035] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application, server, or storage medium performing the operations of this disclosed technical solution, based on the prompt message.

[0036] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.

[0037] It is understood that the above notification and user authorization process are merely illustrative and do not constitute a limitation on the implementation of this disclosure. Other methods that comply with relevant laws and regulations may also be applied to the implementation of this disclosure.

[0038] Meanwhile, it is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.

[0039] This disclosure is primarily applied to wireless network connection scenarios. In a network environment, devices seeking to connect to the network need to obtain network parameters such as IP addresses before connecting. A DHCP server can be used to automatically assign IP addresses to terminals. For example... Figure 1 A DHCP flowchart is an existing wireless network connection process, such as Figure 1As shown, when a terminal first connects to the network, it broadcasts a DHCP Discovery message to locate the DHCP server. Upon receiving the DHCP Discovery message, the DHCP server replies with a DHCP Offer message, which includes the subnet mask, DNS, and the IP address assigned to the terminal. After receiving the first DHCP Offer message, the terminal broadcasts a DHCP Request message to inform the DHCP server that it confirms the use of the IP address assigned by the DHCP server and notifies other hosts in the broadcast that the IP address is already in use. The DHCP server responds with a DHCP ACK message, acknowledging the Request message. Upon receiving this, the client uses the assigned IP address to connect to the wireless network. If the DHCP server receives the Request message but does not find a corresponding lease record, it sends a DHCP NAK message in response, informing the terminal that it cannot assign an IP address. Upon receiving the NAK message, the terminal terminates the current wireless network connection process.

[0040] Based on the existing DHCP process, terminals default to connecting to the wireless network using the IP address in the first received offer message. However, in a network environment with multiple DHCP servers, the IP address in the first received offer message might be an incorrect IP address, preventing the terminal from accessing the internet. Taking connecting to a Wi-Fi network as an example, the router can act as a DHCP server, assigning IP addresses to terminals wanting to connect. However, if the optical modem's network cable is connected to the router's LAN port, it creates a situation where multiple DHCP servers exist in the current Wi-Fi network environment. The router will assign an IP address to the terminal, and the optical modem will also assign an IP address, which is then forwarded to the terminal through the router. In this case, the terminal might use an incorrect IP address, resulting in a Wi-Fi connection but no internet access.

[0041] To address the aforementioned problems, this disclosure provides a method, apparatus, readable medium, and electronic device for connecting to a wireless network. A terminal can initiate a connection to a target wireless network and, after sending a DHCP discovery message, receive a target response message from a target DHCP server in response to the DHCP discovery message. The target DHCP server can be any DHCP server in the current network environment. The target response message carries an IP address assigned to the terminal by the target DHCP server. The terminal can also obtain historical network connection information recorded during the process of connecting to the target wireless network. If it is determined that multiple first response messages are recorded in the historical network connection information, and the terminal's previous wireless network connection was abnormal based on the historical network connection information, if it is determined that the terminal has not used the target response message to connect to the target wireless network, it can connect to the target wireless network according to the target response message. Since different DHCP servers send different first response messages to the terminal, if it is determined that multiple first response messages are recorded in the historical network connection information, it can be determined that there are multiple DHCP servers in the current wireless network environment corresponding to the terminal. In order to avoid the terminal using the wrong IP address to connect to the wireless network in a network environment with multiple DHCP servers, it can connect to the current target wireless network according to the target response message after determining that the terminal has not used the target response message to connect to the target wireless network. This can improve the success rate of wireless network connection and reduce the probability of problems with internet access.

[0042] The specific embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.

[0043] Figure 2 This is a flowchart illustrating a method for connecting to a wireless network according to an exemplary embodiment, such as... Figure 2 As shown, the method includes the following steps:

[0044] In step S201, after sending the DHCP discovery message, a target response message sent by the target DHCP server in response to the DHCP discovery message is received.

[0045] In actual wireless network connection scenarios, after a terminal initiates a connection to the wireless network, it can broadcast a DHCP Discover message to locate the DHCP server that will assign it an IP address. The target response message is called an offer message, and it includes the first IP address assigned to the terminal by the target DHCP server. The target DHCP server can be any DHCP server in the current wireless network environment. For example, in a home Wi-Fi network, if the optical modem is connected to the LAN port of the router, both the optical modem and the router are DHCP servers. The target DHCP server can be either the optical modem or the router.

[0046] In step S202, the historical network connection information recorded by the terminal is obtained.

[0047] This historical network information is typically the historical network information recorded by the terminal during the process of connecting to the target wireless network.

[0048] In a wireless network environment with multiple DHCP servers, to avoid the problem of being unable to access the internet due to a terminal using an inappropriate IP address to connect to the wireless network, in one possible implementation of this disclosure, the terminal can record network information during the connection process. This network information may include the identification information of the connected wireless network (such as the WIFI's BSSID), the wireless network connection result, response messages sent by one or more DHCP servers in response to the DHCP discovery message, and marking information indicating whether each response message was used to connect to the target wireless network. In this way, each time the terminal connects to the target wireless network, it can obtain the historical network information recorded in the terminal's past connections to the target wireless network. This historical network information can be used to determine whether there are multiple DHCP servers in the current network environment, and which offer message was used to connect when the wireless network connection failed last time. Thus, if it is determined that the wireless network being connected this time belongs to the same wireless network as the wireless network being connected last time, a different offer message can be selected for the wireless network connection, thereby improving the success rate of network connection.

[0049] In step S203, if it is determined that multiple first response messages are recorded in the historical network information, and it is determined that the terminal's last wireless network connection was abnormal based on the historical network information, it is determined whether the terminal has used the target response message to connect to the current target wireless network based on the historical network information, and different DHCP servers send different first response messages to the terminal.

[0050] The historical network information records first information representing the last wireless network connection result of the terminal. The wireless network connection result may include whether the wireless network connection is normal or abnormal. Thus, in one implementation, if the data corresponding to the first information is a first preset data (such as "0"), it is determined that the last wireless network connection of the terminal was abnormal.

[0051] Since different DHCP servers send different first response messages to the terminal, if multiple first response messages are recorded in the historical network information, it can be determined that there were multiple DHCP servers in the previously connected wireless network. The first response message actually refers to the offer message sent by different DHCP servers, and the different first response messages carry different IP addresses assigned to the terminal by the DHCP servers.

[0052] In addition, for each first response message, the historical network information also includes second information indicating whether the first response message has been used to connect to the wireless network. For example, 1 can be used to indicate that the first response message has been used, and 0 can be used to indicate that the first response message has not been used. In this way, in this step, the target response message can be determined from multiple first response messages. Based on the second information corresponding to the target response message, it can be determined whether the terminal previously used the target response message to connect to the current target wireless network. For example, if the data corresponding to the second information is determined to be 0, and the currently connected target wireless network and the previously connected wireless network belong to the same network, it can be determined that the terminal previously did not use the target response message to connect to the current target wireless network.

[0053] In step S204, if it is determined that the terminal has not used the target response message to connect to the target wireless network, the terminal connects to the current target wireless network according to the target response message.

[0054] The target response message includes a first IP address assigned to the terminal by the target DHCP server, and the current target wireless network can be, for example, the Wi-Fi network currently connected to the terminal.

[0055] In this step, configuration confirmation information can be sent to the target DHCP server according to the target response message. The configuration confirmation information is used to indicate that the terminal uses the first IP address to connect to the wireless network. For example, the configuration confirmation information can be a DHCP Request message. Upon receiving a second response message sent by the target DHCP server in response to the configuration confirmation information, the terminal connects to the current target wireless network according to the first IP address. The second response message indicates the target DHCP server's confirmation response to the configuration confirmation information. For example, the second response message can be a DHCP ACK message sent by the target DHCP server.

[0056] Using the above method, since different DHCP servers send different first response messages to the terminal, if it is determined that there are multiple first response messages recorded in the historical network information, it can be determined that there are multiple DHCP servers in the current wireless network environment corresponding to the terminal. In order to avoid the terminal using the wrong IP address to connect to the wireless network in a network environment with multiple DHCP servers, it can connect to the current target wireless network according to the target response message after determining that the terminal has not used the target response message to connect to the current target wireless network. This can improve the success rate of wireless network connection and reduce the probability of the inability to access the Internet.

[0057] In practical applications, if a DHCP server receives a DHCP Request message but cannot find a corresponding lease record, it will typically send a DHCP NAK message (hereinafter referred to as the third response message) to the terminal as a response, informing the terminal that an IP address cannot be assigned. Upon receiving the NAK message, the terminal immediately terminates its current wireless network connection. However, considering a multi-DHCP server environment, when a terminal broadcasts a DHCP Request message to DHCP server A, DHCP server B may also receive the same DHCP Request message. It is understandable that the terminal terminating its current wireless network connection upon receiving a DHCP NAK message from DHCP server A is a normal procedure. However, if the terminal terminates its current wireless network connection immediately upon receiving a DHCP NAK message from DHCP server B after sending a DHCP Request message to DHCP server A, this is an abnormal operation. Therefore, to avoid this abnormal operation in this disclosure, such as... Figure 3 As shown, the method also includes the following steps:

[0058] In step S205, upon receiving a third response message in response to the configuration confirmation information, the third response message is parsed to obtain a second IP address. The second IP address is the IP address of the DHCP server that sent the third response message, and the third response message indicates that the DHCP server rejects the configuration confirmation information.

[0059] The third response message can be a DHCP NAK message.

[0060] In step S206, if the second IP address is the IP address of the target DHCP server, the current wireless network connection is terminated.

[0061] For example, assuming the target DHCP server is server A, the terminal receives an offer message from server A. This offer message contains not only the first IP address assigned to the terminal by server A, but also the IP address of server A that sent the offer message. The terminal can obtain the first IP address and server A's IP address by parsing the offer message. After receiving the DHCP NAK message, the terminal can parse it to obtain the second IP address of the DHCP server that sent the message. It can be understood that if the second IP address is the same as server A's IP address, the DHCP NAK message is a NAK message returned by server A, and is therefore a valid message. The terminal can use this DHCP NAK message to exit the current wireless network connection. If the second IP address is different from server A's IP address, the DHCP NAK message is not a NAK message returned by server A, and is therefore invalid. NAK messages are invalid messages. When a terminal receives an invalid message, it does not need to exit the current wireless network connection thread. The above example is only for illustration and this disclosure does not limit it.

[0062] Figure 4 It is based on Figure 2 The illustrated embodiment presents a flowchart of a method for connecting to a wireless network, as shown in the diagram. Figure 4 As shown, the method also includes the following steps:

[0063] In step S207, a network connection test is performed after a preset time period to determine the network connection result.

[0064] Considering that the connection process of a wireless network may be very fast, and the second offer frame may only be received after the connection is completed, in order to receive and save all offer frames in a timely manner, after connecting to the current target wireless network according to the first IP address, a network detection can be performed after a certain period of time. For example, the terminal can start timing from the moment it receives the DHCP ACK message sent by the DHCP server, and start the network detection after 3 seconds (i.e., the preset time period), so that the terminal can receive as many offer messages as possible within the 3-second delay.

[0065] In another possible implementation of this disclosure, network detection can be performed in the following manner: The terminal initiates an ICMP network test to a preset IP address; if the ICMP network test fails, a TCP network test is initiated to the preset IP address; if the TCP network test fails, the connection result of connecting to the target wireless network based on the first IP address is determined to be abnormal.

[0066] The preset IP address may include one or more IP addresses.

[0067] For example, the preset IP can be IP1 and IP2. First, ICMP requests are initiated to the terminals corresponding to IP1 and IP2 respectively. If the ICMP network test fails, a TCP network test can be performed to further test the network connection. Specifically, a TCP SYN handshake request can be initiated to the terminals corresponding to IP1 and IP2 respectively. If the handshake between the terminals corresponding to IP1 and IP2 and the current terminal fails, it is determined that the network connection result of connecting to the target wireless network based on the first IP address is abnormal. In this way, network detection can be performed through two network test methods to improve the accuracy of the detection.

[0068] If it is determined that the connection to the target wireless network based on the first IP address is abnormal, it is necessary to initiate a wireless network reconnection so that a wireless network connection can be established based on another assigned IP address.

[0069] like Figure 4 As shown, the method also includes the following steps:

[0070] In step S208, if the network connection result is determined to be abnormal, it is determined whether there is an unused first response message in the historical network connection information.

[0071] The unused first response message here refers to the offer message that was not used to connect to the target wireless network during the current wireless network connection process or the previous wireless network connection process.

[0072] In step S209, if it is determined that there is an unused first response message in the historical network information, the current target wireless network is disconnected and a thread for reconnecting to the wireless network is started.

[0073] Based on the above method, when the terminal determines that the network connection result is abnormal, it can automatically start a thread to reconnect to the wireless network. After restarting the wireless network connection thread, the terminal can continue to traverse other unused first response messages in the historical network information record and reconnect to the wireless network based on the newly traversed first response messages until it connects to the target wireless network. This can ensure that in an environment with multiple DHCP servers, after the terminal receives multiple assigned IP addresses, it can connect to the wireless network based on the correct IP address, thereby improving the success rate of network connection.

[0074] Considering that the target response message used for the current wireless network connection can only be determined based on the terminal's recorded historical network connection information if the previously connected wireless network and the currently connected wireless network belong to the same network, therefore, if Figure 4 As shown, before performing step S203, the method further includes the following steps:

[0075] In step S210, the network identifier of the last connected wireless network is obtained from the historical network information.

[0076] The network identifier for this wireless network can be either BSSID or SSID.

[0077] In step S211, it is determined whether the previously connected wireless network and the target wireless network are the same wireless network based on the network identifier.

[0078] Obviously, when the network identifier of the last connected wireless network obtained from the historical network information is the same as the network identifier of the target wireless network, it is determined that the last connected wireless network and the target wireless network are the same wireless network.

[0079] Thus, during the execution of step S203, if it is determined that multiple first response messages are recorded in the historical network information, and if it is determined that the terminal's last wireless network connection was abnormal based on the historical network information, and if it is determined that the last connected wireless network and the target wireless network are the same wireless network, then it can be determined whether the terminal has used the target response message to connect to the target wireless network based on the historical network information.

[0080] It should be noted that if it is determined that the previously connected wireless network is not the same wireless network as the target wireless network, the historical network information needs to be cleared to avoid abnormal operations when connecting to a new wireless network based on incorrect historical network information.

[0081] In addition, if it is determined that the previously connected wireless network is not the same wireless network as the target wireless network, the target wireless network can be directly connected to based on the target response message.

[0082] like Figure 4 As shown, the method also includes the following steps:

[0083] In step S212, if the terminal is determined to meet one or more of the following preset conditions based on the historical network information, the number of received offer messages is updated.

[0084] The preset conditions include:

[0085] The terminal had a normal Wi-Fi connection last time;

[0086] The last time the terminal connected to the wireless network was in a single DHCP server scenario.

[0087] The terminal connects to the target wireless network for the first time.

[0088] like Figure 4 As shown, after performing step S212, the method further includes the following steps:

[0089] In step S213, when the number of offer messages is a preset number, the target response message is recorded, and the target wireless network is connected according to the target response message.

[0090] The preset number here can be, for example, 1. That is, when the number of updated offer messages is determined to be 1, it means that the currently received target response message is the first frame offer message, which is the first connection to the target wireless network. The target wireless network can be connected based on the received target response message.

[0091] In step S214, when the number of offer messages is greater than the preset number, the network identifier of the target wireless network and the target response message are recorded, and a preset flag is added to the target response message. The preset flag is used to indicate that the target response message has not been used to connect to the target wireless network.

[0092] For example, when the number of offer messages is greater than 1, the network identifier of the target wireless network and the currently received target response message can be recorded. A preset flag can also be added to the target response message so that after reconnection is initiated, an unused target response message can be selected for wireless network connection based on the currently recorded network information.

[0093] Using the above method, since different DHCP servers send different first response messages to the terminal, if it is determined that there are multiple first response messages recorded in the historical network information, it can be determined that there are multiple DHCP servers in the current wireless network environment corresponding to the terminal. In order to avoid the terminal using the wrong IP address to connect to the wireless network in a network environment with multiple DHCP servers, it can connect to the target wireless network according to the target response message after determining that the terminal has not used the target response message to connect to the current target wireless network. This can improve the success rate of wireless network connection and reduce the probability of the inability to access the Internet.

[0094] Figure 5 This is a block diagram illustrating an apparatus for connecting to a wireless network according to an exemplary embodiment, as shown in FIG5. The apparatus includes:

[0095] The receiving module 501 is used to receive a target response message sent by the target DHCP server in response to the DHCP discovery message after sending a Dynamic Host Configuration Protocol (DHCP) discovery message;

[0096] The acquisition module 502 is used to acquire historical network connection information recorded by the terminal;

[0097] The determination module 503 is used to determine whether the terminal has used the target response message to connect to the current target wireless network when it is determined that there are multiple first response messages recorded in the historical network information and the terminal's last wireless network connection was abnormal according to the historical network information. Different DHCP servers send different first response messages to the terminal.

[0098] The connection module 504 is used to connect to the target wireless network according to the target response message when it is determined that the terminal has not used the target response message to connect to the target wireless network.

[0099] Optionally, the historical network information includes first information characterizing the last wireless network connection result of the terminal, and the determining module 503 is used to determine that the last wireless network connection of the terminal was abnormal when the data corresponding to the first information is a first preset data.

[0100] Optionally, for each first response message, the historical networking information further includes second information indicating whether the first response message has been used to connect to the wireless network. The determining module 503 is used to determine the target response message from multiple first response messages; and to determine whether the terminal has used the target response message to connect to the target wireless network based on the second information corresponding to the target response message.

[0101] Optionally, the target response message includes a first IP address assigned to the terminal by the target DHCP server. The connection module 504 is configured to send configuration confirmation information to the target DHCP server according to the target response message, wherein the configuration confirmation information indicates that the terminal uses the first IP address to connect to the wireless network. Upon receiving a second response message sent by the target DHCP server in response to the configuration confirmation information, the terminal connects to the target wireless network according to the first IP address, wherein the second response message indicates that the target DHCP server confirms the configuration confirmation information.

[0102] Optionally, Figure 6 It is based on Figure 5 The illustrated embodiment shows a block diagram of a device for connecting to a wireless network, as shown in the figure. Figure 6 As shown, the device further includes:

[0103] The connection exit module 505 is used to, upon receiving a third response message in response to the configuration confirmation information, parse the third response message to obtain a second IP address, wherein the second IP address is the IP address of the DHCP server that sent the third response message, and the third response message indicates that the DHCP server rejects the configuration confirmation information; and if the second IP address is the IP address of the target DHCP server, exit the current wireless network connection.

[0104] Optionally, such as Figure 6 As shown, the device further includes:

[0105] The network detection module 506 is used to perform network detection after a preset time period to determine the network connection result.

[0106] Optionally, the network detection module 506 is configured to initiate an ICMP network test to a preset IP address via the terminal; if the ICMP network test fails, initiate a TCP network test to the preset IP address; and if the TCP network test fails, determine that the network connection result of connecting to the target wireless network based on the first IP address is abnormal.

[0107] Optionally, such as Figure 6 As shown, the device further includes: a reconnection module 507, used to determine whether there is an unused first response message in the historical network information when the network connection result is determined to be abnormal; and to disconnect the target wireless network and start a thread to reconnect to the wireless network when it is determined that there is an unused first response message in the historical network information.

[0108] Optionally, such as Figure 6 As shown, the device further includes:

[0109] The network verification module 508 is used to obtain the network identifier of the previously connected wireless network from the historical network information; and determine whether the previously connected wireless network and the target wireless network are the same wireless network based on the network identifier.

[0110] The determining module 503 is used to determine, based on the historical network information, whether the terminal has used the target response message to connect to the target wireless network when it is determined that the previously connected wireless network and the target wireless network are the same wireless network.

[0111] Optionally, such as Figure 6 As shown, the device further includes:

[0112] The record management module 509 is used to clear the historical network information and connect to the target wireless network according to the target response message when it is determined that the previously connected wireless network is not the same wireless network as the target wireless network.

[0113] Optionally, such as Figure 6 As shown, the device further includes:

[0114] The update module 510 is used to update the number of received offer messages when the terminal meets one or more of the following preset conditions based on the historical network information.

[0115] The preset conditions include:

[0116] The terminal had a normal Wi-Fi connection last time;

[0117] The last time the terminal connected to the wireless network was in a single DHCP server scenario.

[0118] The terminal connects to the target wireless network for the first time.

[0119] Optionally, such as Figure 6 As shown, the device further includes:

[0120] The recording module 511 is used to record the target response message and connect to the target wireless network according to the target response message when the number of offer messages is a preset number; when the number of offer messages is greater than the preset number, it records the network identifier of the target wireless network and the target response message, and adds a preset mark to the target response message, the preset mark being used to indicate that the target response message was not used to connect to the target wireless network.

[0121] Using the above-described device, since different DHCP servers send different first response messages to the terminal, if it is determined that multiple first response messages are recorded in the historical network information, it can be determined that there are multiple DHCP servers in the current wireless network environment corresponding to the terminal. In order to avoid the terminal using the wrong IP address to connect to the wireless network in a network environment with multiple DHCP servers, it can connect to the target wireless network according to the target response message after determining that the terminal has not used the target response message to connect to the current target wireless network. This can improve the success rate of wireless network connection and reduce the probability of the inability to access the Internet.

[0122] The following is for reference. Figure 7 The diagram illustrates a structural schematic of an electronic device 700 suitable for implementing embodiments of the present disclosure. Terminals in embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 7 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0123] like Figure 7 As shown, the electronic device 700 may include a processing unit (e.g., a central processing unit, a graphics processor, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703. The RAM 703 also stores various programs and data required for the operation of the electronic device 700. The processing unit 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0124] Typically, the following devices can be connected to I / O interface 705: input devices 706 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 707 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 708 including, for example, magnetic tapes, hard disks, etc.; and communication devices 709. Communication device 709 allows electronic device 700 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 An electronic device 700 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0125] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 709, or installed from storage device 708, or installed from ROM 702. When the computer program is executed by processing device 701, it performs the functions defined in the methods of embodiments of this disclosure.

[0126] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0127] In some implementations, the terminal can communicate using any currently known or future-developed network protocol such as HTTP (Hypertext Transfer Protocol) and can interconnect with digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include local area networks (“LANs”), wide area networks (“WANs”), the Internet (e.g., the Internet of Things), and end-to-end networks (e.g., ad hoc end-to-end networks), as well as any currently known or future-developed networks.

[0128] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0129] The aforementioned computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: receive a target response message sent by a target DHCP server in response to the DHCP discovery message after sending a Dynamic Host Configuration Protocol (DHCP) Discover message; obtain historical network information recorded by the terminal; if it is determined that multiple first response messages are recorded in the historical network information, and the terminal's last wireless network connection was abnormal based on the historical network information, determine whether the terminal has used the target response message to connect to the current target wireless network based on the historical network information, and different DHCP servers send different first response messages to the terminal; if it is determined that the terminal has not used the target response message to connect to the target wireless network, connect to the target wireless network based on the target response message.

[0130] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0131] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0132] The modules described in the embodiments of this disclosure can be implemented in software or in hardware. The name of a module does not necessarily limit the module itself; for example, an acquisition module can also be described as a "module for acquiring historical network information".

[0133] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0134] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0135] According to one or more embodiments of this disclosure, Example 1 provides a method for connecting to a wireless network, including: after sending a Dynamic Host Configuration Protocol (DHCP) Discover message, receiving a target response message sent by a target DHCP server in response to the DHCP Discover message;

[0136] Obtain historical network connection information recorded when the terminal last connected to the wireless network;

[0137] If it is determined that multiple first response messages are recorded in the historical network information, and it is determined that the terminal's last wireless network connection was abnormal based on the historical network information, then it is determined whether the terminal has used the target response message to connect to the current target wireless network based on the historical network information, and different DHCP servers send different first response messages to the terminal.

[0138] If it is determined that the terminal has not used the target response message to connect to the target wireless network, then the terminal connects to the target wireless network according to the target response message.

[0139] According to one or more embodiments of this disclosure, Example 2 provides the method of Example 1, wherein the historical network information includes first information characterizing the last wireless network connection result of the terminal, and the method further includes: determining that the last wireless network connection of the terminal was abnormal when the data corresponding to the first information is a first preset data.

[0140] According to one or more embodiments of this disclosure, Example 3 provides the method of Example 1, wherein for each first response message, the historical networking information further includes second information characterizing whether the first response message has been used to connect to a wireless network, and determining whether the terminal has used the target response message to connect to the current target wireless network based on the historical networking information includes:

[0141] The target response message is determined from multiple first response messages;

[0142] Based on the second information corresponding to the target response message, determine whether the terminal has used the target response message to connect to the target wireless network.

[0143] According to one or more embodiments of this disclosure, Example 4 provides the method of Example 1, wherein the target response message includes a first IP address assigned to the terminal by the target DHCP server, and the step of connecting to the target wireless network according to the target response message includes:

[0144] According to the target response message, a configuration confirmation message is sent to the target DHCP server, and the configuration confirmation message is used to indicate that the terminal uses the first IP address to connect to the wireless network.

[0145] Upon receiving a second response message from the target DHCP server in response to the configuration confirmation information, the target wireless network is connected based on the first IP address, wherein the second response message represents the target DHCP server's confirmation response to the configuration confirmation information.

[0146] According to one or more embodiments of this disclosure, Example 5 provides the method of Example 4, the method further comprising:

[0147] Upon receiving a third response message in response to the configuration confirmation information, the third response message is parsed to obtain a second IP address, which is the IP address of the DHCP server that sent the third response message. The third response message indicates that the DHCP server rejects the configuration confirmation information.

[0148] If the second IP address is the IP address of the target DHCP server, exit the current wireless network connection.

[0149] According to one or more embodiments of this disclosure, Example 6 provides the method of Example 1, which, after connecting to the target wireless network according to the target response message, further includes:

[0150] After a preset time period, a network connection test is performed to determine the network connection result.

[0151] According to one or more embodiments of this disclosure, Example 7 provides the method of Example 6, wherein performing network detection includes:

[0152] The terminal initiates an ICMP network test to a preset IP address.

[0153] If the ICMP network test fails, a TCP network test is initiated against the preset IP address.

[0154] If the TCP network test fails, it is determined that the connection result of connecting to the target wireless network based on the target response message is abnormal.

[0155] According to one or more embodiments of this disclosure, Example 8 provides the method of Example 6, the method further comprising:

[0156] If the network connection result is determined to be abnormal, determine whether there are any unused first response messages in the historical network connection information;

[0157] If it is determined that there is an unused first response message in the historical network information, the target wireless network is disconnected and a thread for reconnecting to the wireless network is started.

[0158] According to one or more embodiments of this disclosure, Example 9 provides a method of any one of Examples 1-8, wherein before determining whether the terminal has used the target response message to connect to the target wireless network based on the historical networking information, the method further includes:

[0159] Obtain the network identifier of the last connected wireless network from the historical network information;

[0160] Based on the network identifier, determine whether the previously connected wireless network and the target wireless network are the same wireless network;

[0161] The step of determining whether the terminal has used the target response message to connect to the current target wireless network based on the historical network information includes:

[0162] If it is determined that the previously connected wireless network and the target wireless network are the same wireless network, the system determines whether the terminal has used the target response message to connect to the target wireless network based on the historical network connection information.

[0163] According to one or more embodiments of this disclosure, Example 10 provides the method of Example 9, the method further comprising:

[0164] If it is determined that the previously connected wireless network is not the same wireless network as the target wireless network, the historical network information is cleared, and the target wireless network is connected according to the target response message.

[0165] According to one or more embodiments of this disclosure, Example 11 provides a method of any one of Examples 1-8, the method further comprising:

[0166] If the terminal is determined to meet one or more of the following preset conditions based on the historical network information, the number of received offer messages is updated.

[0167] The preset conditions include:

[0168] The terminal had a normal Wi-Fi connection last time;

[0169] The last time the terminal connected to the wireless network was in a single DHCP server scenario.

[0170] The terminal connects to the target wireless network for the first time.

[0171] According to one or more embodiments of this disclosure, Example 12 provides the method of Example 11, wherein after updating the number of received offer messages, the method further includes:

[0172] When the number of offer messages is a preset number, the target response message is recorded, and the target wireless network is connected according to the target response message;

[0173] When the number of offer messages exceeds the preset number, the network identifier of the target wireless network and the target response message are recorded, and a preset flag is added to the target response message. The preset flag is used to indicate that the target response message has not been used to connect to the target wireless network.

[0174] According to one or more embodiments of this disclosure, Example 13 provides an apparatus for connecting to a wireless network, the apparatus comprising:

[0175] The receiving module is used to receive a target response message sent by the target DHCP server in response to the DHCP discovery message after sending a Dynamic Host Configuration Protocol (DHCP) discovery message;

[0176] The acquisition module is used to acquire historical network connection information recorded by the terminal.

[0177] The determination module is used to determine whether the terminal has used the target response message to connect to the current target wireless network when it is determined that there are multiple first response messages recorded in the historical network information and the terminal's last wireless network connection was abnormal according to the historical network information. Different DHCP servers send different first response messages to the terminal.

[0178] A connection module is configured to connect to the target wireless network based on the target response message when it is determined that the terminal has not used the target response message to connect to the target wireless network.

[0179] According to one or more embodiments of the present disclosure, Example 14 provides a computer-readable medium having a computer program stored thereon that, when executed by a processing device, implements the steps of the method described in any one of Examples 1-12.

[0180] According to one or more embodiments of this disclosure, Example 15 provides an electronic device, including:

[0181] A storage device on which computer programs are stored;

[0182] A processing device for executing the computer program in the storage device to implement the steps of any one of the methods in Examples 1-12.

[0183] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0184] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0185] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative forms of implementing the claims. Regarding the apparatus in the above embodiments, the specific manner in which the various modules perform their operations has been described in detail in the embodiments relating to the method, and will not be elaborated upon here.

Claims

1. A method of connecting a wireless network, characterized by, The method comprises: after sending a dynamic host configuration protocol (DHCP) discovery message, receiving a target response message sent by a target DHCP server in response to the DHCP discovery message; acquiring historical networking information recorded by a terminal; in a case where it is determined that a plurality of first response messages are recorded in the historical networking information, and that a last wireless network connection of the terminal is abnormal according to the historical networking information, determining whether the terminal has ever connected a current target wireless network using the target response message according to the historical networking information, different DHCP servers sending different first response messages to the terminal; in a case where it is determined that the terminal has not ever connected the target wireless network using the target response message, connecting the target wireless network according to the target response message; in a case where it is determined that a networking result of connecting the target wireless network is abnormal, determining whether there is an unused first response message in the historical networking information; in a case where it is determined that there is an unused first response message in the historical networking information, disconnecting the target wireless network, and starting a thread of reconnecting a wireless network, traversing the unused first response messages recorded in the historical networking information, and reconnecting the wireless network based on a newly traversed first response message until the target wireless network is connected.

2. The method of claim 1, wherein, The historical networking information comprises first information representing a last wireless network connection result of the terminal, and the method further comprises: in a case where data corresponding to the first information is first preset data, determining that the last wireless network connection of the terminal is abnormal.

3. The method of claim 1, wherein, For each first response message, the historical networking information further comprises second information representing whether the first response message has ever been used to connect the target wireless network, and the determination of whether the terminal has ever connected the target wireless network using the target response message according to the historical networking information comprises: determining the target response message from the plurality of first response messages; determining whether the terminal has ever connected the target wireless network using the target response message according to second information corresponding to the target response message.

4. The method of claim 1, wherein, The target response message comprises a first IP address allocated by the target DHCP server for the terminal, and the connection of the target wireless network according to the target response message comprises: sending configuration confirmation information to the target DHCP server according to the target response message, the configuration confirmation information being used to represent that the terminal confirms to use the first IP address to connect the wireless network; in a case where a second response message representing a confirmation response of the target DHCP server to the configuration confirmation information is received from the target DHCP server in response to the configuration confirmation information, connecting the target wireless network according to the first IP address.

5. The method of claim 4, wherein, The method further comprises: In a case that a third response message sent in response to the configuration confirmation information is received, the third response message is parsed to obtain a second IP address, the second IP address is an IP address of a DHCP server sending the third response message, and the third response message represents a rejection response of the DHCP server to the configuration confirmation information; In a case that the second IP address is an IP address of the target DHCP server, the current wireless network connection is exited.

6. The method of claim 1, wherein, After the target wireless network is connected according to the target response message, the method further comprises: After staying for a preset time period, network detection is performed to determine a network connection result.

7. The method of claim 6, wherein, The network detection comprises: initiating an ICMP network test to a preset IP by the terminal; in a case that the ICMP network test fails, initiating a TCP network test to the preset IP; in a case that it is determined that the TCP network test fails, determining that the network connection result of connecting the target wireless network according to the target response message is abnormal.

8. The method according to any one of claims 1 to 7, characterized in that, Before the target response message is determined according to the historical network connection information whether the terminal has ever connected the target wireless network, the method further comprises: obtaining a network identifier of a last connected wireless network from the historical network connection information; determining whether the last connected wireless network and the target wireless network are the same wireless network according to the network identifier; the target response message is determined according to the historical network connection information whether the terminal has ever connected the target wireless network, comprising: in a case that it is determined that the last connected wireless network and the target wireless network are the same wireless network, the target response message is determined according to the historical network connection information whether the terminal has ever connected the target wireless network.

9. The method of claim 8, wherein, The method further comprises: in a case that it is determined that the last connected wireless network and the target wireless network are not the same wireless network, the historical network connection information is emptied, and the target wireless network is connected according to the target response message.

10. The method according to any one of claims 1 to 7, characterized in that, The method further comprises: in a case that it is determined according to the historical network connection information that the terminal meets one or more of the following preset conditions, the number of received offer messages is updated; the preset conditions comprise: the last wireless network connection of the terminal is normal; the last connected wireless network of the terminal is a single DHCP server scenario; the terminal connects the target wireless network for the first time.

11. The method of claim 10, wherein, After the number of received offer messages is updated, the method further comprises: in a case that the number of offer messages is a preset number, the target response message is recorded, and the target wireless network is connected according to the target response message; in a case that the number of offer messages is greater than the preset number, the network identifier of the target wireless network and the target response message are recorded, and a preset mark is added to the target response message, the preset mark is used to represent that the target response message is not used to connect the target wireless network.

12. An apparatus for a wireless network, the apparatus comprising: The device comprises: a receiving module, configured to receive a target response message sent by a target dynamic host configuration protocol (DHCP) server in response to a DHCP discovery message after the DHCP discovery message is sent. The acquisition module is configured to acquire historical networking information recorded by a terminal; The determination module is configured to, in a case where it is determined that a plurality of first response messages are recorded in the historical networking information and that the terminal last time has an abnormal wireless network connection according to the historical networking information, determine whether the terminal has ever connected to a current target wireless network using the target response message according to the historical networking information, and different first response messages are sent to the terminal by different DHCP servers; The connection module is configured to, in a case where it is determined that the terminal has not ever connected to the target wireless network using the target response message, connect to the target wireless network according to the target response message; In a case where it is determined that the networking result of connecting to the target wireless network is abnormal, it is determined whether there is an unused first response message in the historical networking information; In a case where it is determined that there is an unused first response message in the historical networking information, the target wireless network is disconnected, and a thread of reconnecting to a wireless network is started, the unused first response message recorded in the historical networking information is traversed, and wireless network connection is re-performed based on a newly traversed first response message until the target wireless network is connected.

13. A computer readable medium having stored thereon a computer program, characterized in that, The program is executed by the processing device to implement the steps of the method of any one of claims 1-11.

14. An electronic device, comprising: Comprise: A storage device having a computer program stored thereon; A processing device configured to execute the computer program in the storage device to implement the steps of the method of any one of claims 1-11.

Citation Information

Patent Citations

  • Method and apparatus for keeping network connection alive under a dynamic address configuration

    WO2012109841A1