Summary of the invention
The invention provides a kind of method for switching network and terminal, the method can, in the time that terminal can not be used WLAN access the Internet, be switched terminal into mobile network from WLAN automatically.
First aspect present invention provides a kind of method for switching network, comprising:
Terminal accessing WLAN network;
After described terminal accesses described WLAN, whether WLAN can access the Internet described in described terminal judges;
If described WLAN can not be accessed the Internet, described terminal disconnects described WLAN, and uses mobile network.
In conjunction with first aspect present invention, in the first possibility implementation of first aspect, before described terminal accessing WLAN network, described method comprises:
In the time that terminal is used mobile network, terminal detects accessible WLAN.
In conjunction with the first possibility implementation of first aspect present invention or first aspect, in the second possibility implementation of first aspect, described terminal accessing WLAN network, comprising:
Described terminal connects described WLAN, and obtains the routing iinformation of described WLAN;
Described terminal is according to the routing iinformation of the described WLAN getting, and default route is set to the route of described WLAN, makes described terminal access described WLAN.
In conjunction with the second possibility implementation of first aspect present invention, in the third possibility implementation of first aspect, the route that described terminal is set to described WLAN according to the routing iinformation default route of the described WLAN getting specifically comprises:
Described terminal default route is set to the route while of described WLAN, and described mobile network's route is retained in routing table.
In conjunction with first aspect present invention, in the 4th kind of possibility implementation of first aspect, if described WLAN can not be accessed the Internet, described terminal disconnects described WLAN, and uses mobile network, comprising:
Default route is set to described mobile network's route, makes described terminal access to mobile network.
In conjunction with first to fourth any one possibility implementation of first aspect present invention or first aspect, in the 5th kind of possibility implementation of first aspect, after described terminal disconnects described WLAN, described method also comprises:
Described terminal is made as described WLAN to forbid the limited network of access automatically.
In conjunction with first to the 5th any one possibility implementation of first aspect present invention or first aspect, in the 6th kind of possibility implementation of first aspect, before described terminal accesses described WLAN, also comprise:
In the time that described terminal detects described WLAN, judge whether described WLAN is that described terminal is forbidden the limited network of access automatically;
When described WLAN is not described terminal while forbidding the limited network of automatically access, described terminal accesses described WLAN.
Second aspect present invention provides a kind of terminal, comprising:
Access unit, for accessing WLAN network;
Judging unit, for after described access unit accessing WLAN network, judges whether described WLAN can access the Internet;
Switch unit, if judge that for described judging unit described WLAN can not access the Internet, disconnects described access unit and described WLAN, and uses mobile network.
In conjunction with second aspect present invention, in the first possibility implementation of second aspect, described terminal also comprises:
Detecting unit, for before described access unit accessing WLAN network, in the time that described terminal is used mobile network, detects accessible WLAN.
In conjunction with the first possibility implementation of second aspect present invention or second aspect, in the second possibility implementation of second aspect, described access unit, for accessing WLAN network, comprising:
Be used for: connect described WLAN, and obtain the routing iinformation of described WLAN; And according to the routing iinformation of the described WLAN getting, default route is set to the route of described WLAN, make described access unit access described WLAN.
In conjunction with the second possibility implementation of second aspect present invention, in the third possibility implementation of second aspect, described access unit, for be set to the route of described WLAN according to the routing iinformation default route of the described WLAN getting, comprising:
The route while that is set to described WLAN for default route, described mobile network's route is retained in routing table.
In conjunction with second aspect present invention, in the 4th kind of possibility implementation of second aspect, described switch unit, if judge that for described judging unit described WLAN can not access the Internet, described access unit and described WLAN are disconnected, and use mobile network, comprising: be set to described mobile network's route for default route, make described access unit access to mobile network.
In conjunction with first to fourth any one possibility implementation of second aspect present invention or second aspect, in the 5th kind of possibility implementation of second aspect, described access unit also, for after described switch unit is by described terminal and the disconnection of described WLAN, is made as described WLAN to forbid the limited network of access automatically.
In conjunction with first to the 5th any one possibility implementation of second aspect present invention or second aspect, in the 6th kind of possibility implementation of second aspect, described access unit is also in the time that described detecting unit detects described WLAN, judge whether described WLAN is that described terminal is forbidden the limited network of access automatically, when described WLAN is not described terminal while forbidding the limited network of automatically access, described access unit is accessed to described WLAN.
In the present invention, terminal can judge whether the WLAN of access can access the Internet, if WLAN can not be accessed the Internet, can switch into mobile network from WLAN, thereby can keep the network of terminal unimpeded, avoid data service to interrupt, improve user and experience.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiment.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
As shown in Figure 1, a kind of method that the embodiment of the present invention 1 provides network to switch, comprising:
101, terminal accessing WLAN network.
The terminal here can be mobile phone, panel computer or other mobile terminals.Terminal can be in the time being used mobile network, accessing WLAN network.For example, in the time that terminal is used mobile network to process business, detect around and have WLAN, terminal can access this WLAN.
102,, after described terminal accessing WLAN network, whether WLAN can access the Internet described in described terminal judges.
For example, terminal is by dns resolution domain name, if can get corresponding IP address, judges that WLAN can access the Internet, if can not get corresponding IP address, judges that WLAN can not access the Internet.Or, use ping function to connect a network address, if receive response, judge that WLAN can access the Internet, if do not receive response, judge that WLAN can not access the Internet.Or whether terminal judges http request is redirected, if be redirected, judge by WLAN and can access the Internet, if be not redirected, judged by WLAN and can not access the Internet.Terminal can also receive the notice that network side sends, and judges according to this notice whether described WLAN can access the Internet.For example, when terminal from network side receives when representing that described WLAN can be accessed the notice of the Internet, judge that described WLAN can access the Internet, in the time that terminal from network side receives the notice for representing to refuse terminal access, judge that described WLAN can not access the Internet.
If 103 described WLAN can not be accessed the Internet, described terminal disconnects described WLAN, uses mobile network.
Described mobile network can comprise the networks such as LTE, 3G or 2G.
Application the present embodiment method, in the time that terminal can not be accessed the Internet by WLAN, terminal can be switched back mobile network from WLAN automatically, thereby keeps the network of terminal unimpeded.
For clearer description the present invention, below enumerate again embodiment and describe.
As shown in Figure 2, a kind of method that the embodiment of the present invention 2 provides network to switch, comprising:
201, terminal detects and whether has WLAN around.
For example, terminal is used mobile network to access the Internet, detects simultaneously and whether has WLAN around.
202,, in the time that terminal detects WLAN, judge whether the WLAN detecting is that terminal is forbidden the limited network of access automatically.
Concrete, user or system can arrange the list of limited network in terminal, in the time that terminal detects WLAN, travel through the WLAN recording in the list of this limited network, if the WLAN detecting is not in the list of this limited network, the WLAN that judgement detects is not that terminal is forbidden the limited network of access automatically, if the WLAN detecting is in the list of this limited network, the WLAN that judgement detects is that terminal is forbidden the limited network of access automatically.
If it is that terminal is forbidden the limited network of access automatically that step 202 judges the WLAN detecting, perform step 209.
If it is not that terminal is forbidden the limited network of access automatically that step 202 judges the WLAN detecting, perform step 203.
203, terminal connects WLAN, and obtains the routing iinformation of WLAN.
Concrete, the WLAN detecting when judgement is not that terminal is while forbidding the limited network of access automatically, terminal can point out user to connect WLAN, after terminal is connected WLAN by user's manual operation, terminal successfully connects WLAN, and in routing table, adds the routing iinformation of WLAN.The WLAN that terminal also can detect in judgement is not terminal while forbidding the limited network of automatically access, and the WLAN that is certainly dynamically connected is added the routing iinformation of WLAN in routing table.If there are multiple WLAN situations, terminal can provide WLAN list to user, in WLAN list, comprise all detect can for connect WLAN, make user can select needed WLAN.
204, according to the routing iinformation of the described WLAN getting, default route is set to the route of WLAN, makes described terminal access described WLAN.
In step 204, described terminal is set to the route while of described WLAN at default route, described mobile network's route is retained in routing table, and automatic accessing WLAN network.Because terminal has retained mobile network's route in routing table, therefore terminal can be used mobile network's route, access to mobile network at any time.
205, whether terminal judges WLAN can access the Internet.
If terminal judges WLAN can be accessed the Internet, perform step 206.
If terminal judges WLAN can not be accessed the Internet, perform step 207.
206, terminal is used WLAN access the Internet.
207, default route is set to described mobile network's route, makes described terminal access to mobile network, simultaneously disconnection of wireless LAN.
208, the WLAN of disconnection is made as to limited network.
Concrete, in the time of terminal disconnection of wireless LAN, WLAN is added in the list of limited network, avoid terminal again can not access the WLAN of the Internet from being dynamically connected.
209, use mobile network to access the Internet.
The step of carrying out above-described embodiment 2, can make terminal in the time that WLAN can not be accessed the Internet, can switch in time mobile network.Switch route and detect WLAN required time extremely short due to terminal, it is hereby ensured that the ongoing data service of terminal do not interrupt, can keep the unobstructed of network.
As shown in Figure 3, in the present embodiment 2, in execution step 203, terminal connects WLAN, and after obtaining the routing iinformation of WLAN, can also perform step 210.
210, judge whether WLAN is exception network.
Exception network is to allow the terminal network of access automatically, and terminal is automatically accessing after this network, directly disconnects mobile network.User or system can be set exception net list in terminal, the information that comprises the network that makes an exception in exception net list, in the time judging whether WLAN is exception network, can be by the traversal net list that makes an exception, if WLAN is not in this exception net list, judging that WLAN is not exception network, is exception network if WLAN in this exception net list, judges WLAN.
In the time judging that WLAN belongs to exception network, execution step 211; In the time judging that WLAN does not belong to exception network, execution step 212.
211, terminal disconnects mobile network, and default route is set to WLAN.
212, whether terminal judges needs manual access network.
In the time that judgement needs manual access network, perform step 213.
In the time that judgement does not need manual access network, carry out above-mentioned steps 204.
213, prompting user carries out the operation of manual accessing WLAN network.
From step 210 to 213, when WLAN is exception network, or while needing manually access, terminal can directly disconnect mobile network, and default route is set to the route of WLAN, without continuing extra execution step.
As shown in Figure 4, the embodiment of the present invention 3 provides a kind of terminal 304, comprising:
Access unit 301, for accessing WLAN network;
Judging unit 302, for after described access unit 301 accessing WLAN networks, judges whether WLAN can access the Internet;
Switch unit 303, if judge that for described judging unit 302 described WLAN can not access the Internet, disconnects described access unit 301 and described WLAN, and uses mobile network.
The terminal that the present embodiment provides can, in the time can not accessing the Internet by WLAN, be switched back mobile network from WLAN automatically, thereby keeps the network of terminal unimpeded.
As shown in Figure 5, the embodiment of the present invention 4 provides a kind of terminal 404, comprising:
Access unit 401, for accessing WLAN network;
Judging unit 402, for after described access unit 401 accessing WLAN networks, judges whether WLAN can access the Internet;
Switch unit 403, if judge that for described judging unit 402 WLAN can not access the Internet, disconnects described access unit 401 and described WLAN, and uses mobile network.
Detecting unit 405, for before described access unit 401 is by described terminal accessing WLAN network, in the time that described terminal is used mobile network, detects accessible WLAN.
Preferably, described access unit 401, for by described terminal 404 accessing WLAN networks, comprising:
Be used for: connect described WLAN, and obtain the routing iinformation of described WLAN; And according to the routing iinformation of the described WLAN getting, default route is set to the route of described WLAN, make described access unit 401 access described WLAN.
Preferably, described access unit 401, for be set to the route of described WLAN according to the routing iinformation default route of the described WLAN getting, comprising:
The route while that is set to described WLAN for default route, described mobile network's route is retained in routing table.
Preferably, described switch unit 403, if judge that for described judging unit 402 described WLAN can not access the Internet, described access unit 401 and described WLAN are disconnected, and use mobile network, comprise: be set to described mobile network's route for default route, make described access unit 401 access to mobile network.
Preferably, described access unit 401 also, for after described switch unit 403 disconnects described access unit 401 and described WLAN, is made as described WLAN to forbid the limited network of access automatically.
Preferably, described access unit 401 is also in the time that described detecting unit 405 detects described WLAN, judge whether described WLAN is that described terminal 404 is forbidden the limited network of access automatically, when described WLAN is not described terminal 404 while forbidding the limited network of automatically access, access described WLAN.
As shown in Figure 6, the embodiment of the present invention 5 provides a kind of terminal 501, comprising:
Transceiver 502, for accessing WLAN network;
Processor 503, connects transceiver 502, for after described transceiver 502 accesses described WLAN, judges whether described WLAN can access the Internet;
If described transceiver 502 also judges that for described processor 503 described WLAN can not access the Internet, disconnect being connected of described transceiver 502 and described WLAN, and use mobile network.
Preferably, described transceiver 502, also for before accessing WLAN network, in the time using mobile network, detects accessible WLAN.
Preferably, described terminal 501 accessing WLAN networks, comprising:
Described transceiver 502 connects described WLAN, and obtains the routing iinformation of described WLAN;
The routing iinformation of the described WLAN that described processor 503 gets according to described transceiver 502, default route is set to the route of described WLAN, makes described transceiver 502 access described WLAN.
Preferably, the route that described processor 503 is set to described WLAN for the routing iinformation default route of the described WLAN that gets according to described transceiver 502 specifically comprises:
Described processor 503 is set to the route while of described WLAN for default route, described mobile network's route is retained in routing table.
Preferably, if described processor 503 can not be accessed the Internet for described WLAN, default route is set to described mobile network's route, makes described transceiver 502 access to mobile network.
Preferably, described processor 503, also for after described transceiver 502 and described WLAN disconnect, is made as described WLAN to forbid the limited network of access automatically.
Preferably, described processor 503 is also for before accessing described WLAN at described transceiver 502, in the time that described transceiver 502 detects described WLAN, judge whether described WLAN is that described terminal 501 is forbidden the limited network of access automatically;
Described transceiver 502 also, for when described WLAN not being described terminal 501 while forbidding the limited network of automatically access, accesses described WLAN.
In specific implementation, the present invention also provides a kind of computer-readable storage medium, wherein, this computer-readable storage medium can have program stored therein, and can comprise the part or all of step in each embodiment of the exchange configuration method based on virtual networking provided by the invention to program while execution.Described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc.
Method and terminal that a kind of the network above embodiment of the present invention being provided switches are described in detail, applied specific case herein principle of the present invention and execution mode are set forth, the explanation of above embodiment is just for helping to understand method of the present invention and core concept thereof; , for one of ordinary skill in the art, according to thought of the present invention, all will change in specific embodiments and applications, in sum, this description should not be construed as limitation of the present invention meanwhile.