CN105554151B - A kind of keep-alive time determines method and electronic equipment - Google Patents
A kind of keep-alive time determines method and electronic equipment Download PDFInfo
- Publication number
- CN105554151B CN105554151B CN201511021003.4A CN201511021003A CN105554151B CN 105554151 B CN105554151 B CN 105554151B CN 201511021003 A CN201511021003 A CN 201511021003A CN 105554151 B CN105554151 B CN 105554151B
- Authority
- CN
- China
- Prior art keywords
- keep
- electronic equipment
- connection
- alive time
- alive
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
Abstract
The embodiment of the present application provides a kind of keep-alive time and determines method and electronic equipment, this method comprises: carrying out predetermined registration operation when the first electronic equipment is connected to local area network, obtaining operating result;When the operating result shows the keep-alive time that first electronic equipment gets the second connection from the second electronic equipment in the local area network, it is determined that the keep-alive time of the first connection between first electronic equipment and given server is the keep-alive time of second connection;Wherein, second electronic equipment is different from first electronic equipment.This method and electronic equipment can reduce power wastage caused by the determining keep-alive time.
Description
Technical field
This application involves field of communication technology, more particularly to a kind of keep-alive time determines that method and electronics are set
It is standby.
Background technique
There are long connection and short connection in TCP (Transmission Control Protocol, transmission control protocol)
Point.Wherein, TCP long can still keep connecting within a certain period of time after being connected to transmission data packet.
If electronic equipment wishes TCP long, connection is kept, and needs to send a keep-alive to server at regular intervals
Request, however frequently send keep-alive request and inevitably result in that equipment power dissipation is excessive, in order to reduce the number of keep-alive request, electronics is set
In the case where the standby long connection no data transmission needed to detect between the electronic equipment and server, length connection can be maintained
Maximum time, i.e., detection the keep-alive time, and before reaching the keep-alive time send keep-alive request, with reduce keep-alive request hair
Send number.But during the electronic equipment detection keep-alive time, a large amount of power consumptions of electronic equipment will necessarily be also expended, thus
It results in waste of resources.
Summary of the invention
In view of this, this application provides a kind of keep-alive times to determine method and electronic equipment, when determining keep-alive to reduce
Between caused by power wastage.
To achieve the above object, the application provides the following technical solutions:
A kind of keep-alive time determines method, comprising:
When the first electronic equipment is connected to local area network, predetermined registration operation is carried out, operating result is obtained;
When the operating result shows that first electronic equipment is got from the second electronic equipment in the local area network
When the keep-alive time of the second connection, it is determined that when the keep-alive of the first connection between first electronic equipment and given server
Between be it is described second connection the keep-alive time, wherein it is described second connection the keep-alive time be second electronic equipment and institute
State second between given server be connected to no data transmission in the case where, it is described second connection can maintain maximum when
It is long;Wherein, second electronic equipment is different from first electronic equipment.
Preferably, the carry out predetermined registration operation, obtains operating result, comprising:
The broadcast message that at least one second electronic equipment in the local area network is sent is detected, testing result is obtained;
Then the operating result shows that first electronic equipment is got from the second electronic equipment in the local area network
The keep-alive time of second connection, comprising:
Testing result shows to detect the broadcast message, and the broadcast message carries the keep-alive of second connection
Time.
Preferably, the carry out predetermined registration operation, obtains operating result, comprising:
Broadcast message is sent in the local area network, when the broadcast message is for requesting the keep-alive of second connection
Between;
Obtain the response message that at least one second electronic equipment is returned for the broadcast message in the local area network;
Then the operating result shows that first electronic equipment is got from the second electronic equipment in the local area network
The keep-alive time of second connection, comprising:
It include the keep-alive time of second connection in the response message.
Preferably, further includes:
When the operating result shows that the keep-alive time of second connection has not been obtained, obtains second electronics and set
The detection event of the standby keep-alive time currently connected to described second;
When the detection event shows that getting second electronic equipment currently detects the keep-alive of second connection
Between used by first detection duration when, based on it is described first detection duration, detect it is described first connection the keep-alive time.
Preferably, described when the detection event shows that getting second electronic equipment currently detects second company
Used by the keep-alive time connect when the first detection duration, based on the first detection duration, the guarantor of first connection is detected
Live time, comprising:
When the detection event shows that getting at least two second electronic equipments currently detects the described second guarantor connected
Used by live time when the first detection duration, the first detection duration used by least two second electronic equipment
In, determine maximum probe duration;
Based on the maximum probe duration, the keep-alive time of first connection is detected.
Preferably, described when the detection event shows that getting second electronic equipment currently detects second company
Used by the keep-alive time connect when the first detection duration, based on the first detection duration, the guarantor of first connection is detected
Live time, comprising:
Described is currently detected when the detection result shows to get the second electronic equipment of setting in the local area network
Used by the keep-alive time of two connections when the first detection duration, based on the first detection duration, first connection is detected
The keep-alive time, it is described set the second electronic equipment as before first electronic equipment the last time be connected to the local
Second electronic equipment of net.
Preferably, after the keep-alive time for detecting first connection, further includes:
The keep-alive time that described first connects is sent to the second electronic equipment in the local area network, so that described
The keep-alive time that two electronic equipments are connected described first is as between second electronic equipment and the given server
The keep-alive time of second connection.
Preferably, before the keep-alive time for detecting first connection, further includes:
When detecting that third electronic equipment is connected to the local area network, the keep-alive for currently detecting first connection is determined
Second detection duration used in time;
The second detection duration is sent to the third electronic equipment, so that the third electronic equipment is based on institute
The second detection duration is stated, the keep-alive time of the third connection between the third electronic equipment and the given server is carried out
Detection.
On the other hand, the embodiment of the present application also provides a kind of electronic equipment, comprising:
Processor, for carrying out predetermined registration operation, obtaining operating result when the electronic equipment is connected to local area network;When
The operating result shows that the electronic equipment gets the keep-alive of the second connection from the second electronic equipment in the local area network
When the time, it is determined that the keep-alive time of the first connection between the electronic equipment and given server is second connection
The keep-alive time, wherein the keep-alive time of second connection is between second electronic equipment and the given server
In the case that second is connected to no data transmission, described second connects the maximum time that can be maintained;Wherein, second electronics
Equipment is different from the electronic equipment;
Memory, for data needed for storing the processor operation.
Preferably, further includes: receiver, for receiving the transmission of at least one second electronic equipment in the local area network
Broadcast message;
Then, processor, specifically for detecting in the local area network at least when the electronic equipment is connected to local area network
The broadcast message that one the second electronic equipment is sent obtains testing result;When the testing result shows that the receiver receives
To the broadcast message, and when the broadcast message carries the keep-alive time of second connection, it is determined that the electronics is set
The keep-alive time of standby the first connection between given server is the keep-alive time of second connection.
Preferably, further includes:
Transmitter, for sending broadcast message in the local area network, the broadcast message connects for requesting described second
The keep-alive time connect;
Receiver is directed to what the broadcast message returned for obtaining at least one second electronic equipment in the local area network
Response message;
Then, the processor is sent specifically for when the electronic equipment is connected to local area network, triggering the transmitter
The broadcast message;It when detecting that the receiver receives the response message, and include described the in the response message
When the keep-alive time of two connections, it is determined that the keep-alive time of the first connection between the electronic equipment and given server is institute
State the keep-alive time of the second connection.
Preferably, the processor is also used to when the operating result show that the described second keep-alive connected has not been obtained
When the time, second electronic equipment is obtained currently to the detection event of the keep-alive time of second connection;The detection feelings
When condition shows the first detection used by getting the keep-alive time that second electronic equipment currently detects second connection
When long, based on the first detection duration, the keep-alive time of first connection is detected.
Preferably, described in the processor shows that getting second electronic equipment currently detects when the detection event
Used by the keep-alive time of second connection when the first detection duration, based on the first detection duration, detects described first and connect
The keep-alive time connect, specifically:
When the detection event shows that getting at least two second electronic equipments currently detects the described second guarantor connected
Used by live time when the first detection duration, the first detection duration used by least two second electronic equipment
In, determine maximum probe duration;Based on the maximum probe duration, the keep-alive time of first connection is detected.
Preferably, described in the processor shows that getting second electronic equipment currently detects when the detection event
Used by the keep-alive time of second connection when the first detection duration, based on the first detection duration, detects described first and connect
The keep-alive time connect, specifically:
Described is currently detected when the detection result shows to get the second electronic equipment of setting in the local area network
Used by the keep-alive time of two connections when the first detection duration, based on the first detection duration, first connection is detected
The keep-alive time, it is described to set the second electronic equipment and be connected to the local area network to be the last before the electronic equipment
Second electronic equipment.
Preferably, the processor is also used to, after the keep-alive time for detecting first connection, by described first
The keep-alive time of connection is sent to the second electronic equipment in the local area network, so that second electronic equipment is by described
Keep-alive time of the keep-alive time of one connection as the second connection between second electronic equipment and the given server.
Preferably, the processor is also used to, before the keep-alive time for detecting first connection, when detecting the
When three electronic equipments are connected to the local area network, the second detection used in the keep-alive time for currently detecting first connection is determined
Duration;The second detection duration is sent to the third electronic equipment, so that the third electronic equipment is based on described
Second detection duration visits the keep-alive time of the third connection between the third electronic equipment and the given server
It surveys.
It can be seen via above technical scheme that carrying out predetermined registration operation when the first electronic equipment is connected to local area network to obtain
To operating result, due in local area network any one keep-alive time connected between equipment and given server be it is identical,
In this way, showing that the second electronic equipment out of this local area network gets second electronic equipment and given server in operating result
Between second connection the keep-alive time when, can directly using second connection the keep-alive time as first electronic equipment with should
The keep-alive time of the first connection between given server, detect the keep-alive of first connection again without the first electronic equipment
Time, and then resource cost caused by the detection keep-alive time can be reduced.
Detailed description of the invention
Technical solution in ord to more clearly illustrate embodiments of the present application, below will be to required use in embodiment description
Attached drawing be briefly described, it should be apparent that, the accompanying drawings in the following description is only embodiments herein, for this field
For those of ordinary skill, without creative efforts, it can also be obtained according to the attached drawing of offer other attached
Figure.
Fig. 1 shows the flow diagram that the application determines method one embodiment a kind of keep-alive time;
Fig. 2 shows the flow diagrams that the application determines another embodiment of method a kind of keep-alive time;
Fig. 3 shows a kind of flow diagram for detecting the keep-alive time;
Fig. 4 shows the structural schematic diagram of the application a kind of electronic equipment one embodiment.
Specific embodiment
The embodiment of the present application provides a kind of keep-alive time and determines method and electronic equipment, determines keep-alive time institute to reduce
Caused power wastage.
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of embodiments of the present application, instead of all the embodiments.It is based on
Embodiment in the application, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall in the protection scope of this application.
Method, which is introduced, to be determined to a kind of keep-alive time of the embodiment of the present application first.
Referring to Fig. 1, it illustrates the flow diagram that the application determines method one embodiment a kind of keep-alive time, this realities
The method for applying example may include:
101, when the first electronic equipment is connected to local area network, predetermined registration operation is carried out, operating result is obtained.
The mode that equipment is connected to local area network can be existing any way, not limit herein.
In the embodiment of the present application, when the first electronic equipment is connected to local area network, it will do it predetermined registration operation, to obtain this
First electronic equipment and given server establish the keep-alive time corresponding to connection.
102, when the operating result shows that first electronic equipment gets from the second electronic equipment in the local area network
Two connection the keep-alive time when, it is determined that between first electronic equipment and given server first connection the keep-alive time be
The keep-alive time of second connection.
Wherein, the second electronic equipment is different from first electronic equipment, second electronic equipment can be understood as this
One electronic equipment is connected to before the local area network, is connected to the electronic equipment of the local area network.
This second is connected as connection between the second electronic equipment and the given server in the local area network.
It should be noted that the first connection connect to distinguish the first electronic equipment and the local area network with second
The connection between the second electronic equipment and the given server except interior first electronic equipment.Optionally, the application is implemented
Connection described in example between electronic equipment and the given server can be understood as TCP long connection.
After the keep-alive time can be understood as the connection that electronic equipment and the server are established, in the connection, there is no data biographies
In the case where defeated, maximum time which can maintain.The keep-alive time can be understood as the local area network in the present embodiment
Keep-alive duration corresponding to connection between interior electronic equipment and the given server.Such as, the keep-alive time of the second connection is
In the case that second between second electronic equipment and the given server is connected to no data transmission, which can be tieed up
The maximum time held.
Present inventor it has been investigated that: the chain of the connection established between the device and the server road, general meeting
With the presence of multi-stage router, and in the case where router is not received by communication data for a long time, router will be by the company
Relevant information deletion is connect, such as is deleted from NAT (Network Address Translation, network address translation) list
Except the information of long connection, so that the connection between the equipment and server cannot keep.In order to get equipment and service
The maximum keep-alive duration connected between device, the chain road router that electronic equipment can detect connection update connection relevant information
Shortest time, such as the shortest time (the also referred to as ageing time of NAT list) of NAT list is updated, it is true based on the shortest time
Determine the keep-alive time.
For equipment in a local area network, any one equipment in the local area network is established with same server to be connected
After connecing, the multi-stage router that the connecting link of foundation is passed through all be it is identical, therefore, router more new equipment and server it
Between shortest time for connecting be also it is identical, in other words, connected between arbitrary equipment and same server in same local area network
The keep-alive time is identical.Therefore, as long as in the local area network any one equipment detect the equipment and same server it
After the keep-alive time of preceding connection, the other equipment in the local area network then no longer need to detect the keep-alive time, and can be straight
It connects and connects the corresponding keep-alive time between the server as itself using the keep-alive time.
It is above the study found that if the operating result shows to get the second electronics in the local area network based on inventor
When keep-alive time between equipment and given server, then the keep-alive time that first electronic equipment can directly will acquire is made
The keep-alive time corresponding to the connection established between first electronic equipment and the given server.
As it can be seen that in the embodiment of the present application, when the first electronic equipment is connected to local area network, carrying out predetermined registration operation to obtain
Operating result, due in local area network any one keep-alive time connected between equipment and given server be it is identical, this
Sample, operating result show the second electronic equipment out of this local area network get second electronic equipment and given server it
Between second connection the keep-alive time when, can directly using second connection the keep-alive time refer to as first electronic equipment with this
The keep-alive time for determining the first connection between server, when detecting the keep-alive of first connection again without the first electronic equipment
Between, and then resource cost caused by the detection keep-alive time can be reduced.
It should be noted that after the first electronic equipment is connected to the local area network, in order to determine in the local area network whether deposit
Detected the keep-alive time in the second electronic equipment, the predetermined registration operation which is carried out can be actively into
Row operation, is also possible to the operation passively received.
In one possible implementation, in local area network any electronic equipment after detecting the keep-alive time,
To broadcast the message into the local area network, to pass through the broadcast message for the keep-alive time announcement to the other equipment in local area network.
In that case, when the first electronic equipment is connected in the local area network, it can detecte at least one in local area network
The broadcast message that a second electronic equipment is sent, and obtain testing result.If the testing result shows to detect that the broadcast disappears
Breath, and the broadcast message carry this second connection the keep-alive time, then using the second keep-alive time connected as this first
The keep-alive time of connection.
It, can be into local area network when which is connected to local area network in alternatively possible implementation
Broadcast message is sent, which is used to request the keep-alive time of second connection.If the second electronics in the local area network
After equipment receives broadcast message, if it is confirmed that itself detected the keep-alive time, then it can be by second electronic equipment
The keep-alive time of corresponding second connection is sent to first electronic equipment.Correspondingly, the available office of the first electronic equipment
It nets at least one interior second electronic equipment and is directed to the response message that the broadcast message returns in domain;If including the in the response message
The second keep-alive time connected is then determined as the keep-alive time of first connection by the keep-alive time of two connections.
Optionally, after first electronic equipment is connected to the local area network, which can also establish this
The first connection between first electronic equipment and the given server.It, can be in this way, after getting the keep-alive time of the second connection
First connection is maintained according to the keep-alive time of second connection.
Referring to fig. 2, it illustrates the flow diagrams that the application determines another embodiment of method a kind of keep-alive time, originally
The method of embodiment may include:
201, when the first electronic equipment is connected to local area network, predetermined registration operation is carried out, operating result is obtained.
202, when the operating result shows that first electronic equipment gets from the second electronic equipment in the local area network
Two connection the keep-alive time when, it is determined that between first electronic equipment and given server first connection the keep-alive time be
The keep-alive time of second connection.
Step 201 and step 202 may refer to the related introduction of preceding embodiment, and details are not described herein.
203, when the operating result shows that the keep-alive time of second connection has not been obtained, obtain second electronic equipment
Currently to the detection event of the keep-alive time of second connection.
Wherein, the mode for obtaining the detection event can be similar with the front mode for obtaining the keep-alive time that second connect.
Such as, the first electronic equipment can send broadcast message into local area network, which can indicate that first electronic equipment connects
It is connected to local area network, which, which can also be, indicates that second electronic equipment returns currently to the detection event of keep-alive time;
In this way, the second electronic equipment detects the broadcast message, then can return currently to the detection event of keep-alive time.
Optionally, in step 201, the first electronic equipment is broadcast the message by sending into local area network, carrys out request
When the keep-alive time that the second electronic equipment determines, if the second electronic equipment does not detect the keep-alive time, the second electricity currently
Sub- equipment can also be returned directly currently to the detection result of the keep-alive time, this way it is possible to avoid the first electronic equipment is again
Broadcast message is sent to obtain the detection event of keep-alive time.Correspondingly, the first electronic equipment can receive the second electronic equipment
Return to detection event.
204, when the detection event shows to get the keep-alive time institute that second electronic equipment currently detects the second connection
When the first detection duration used, based on the first detection duration, the keep-alive time of first connection is detected.
It should be noted that detection duration is different from the keep-alive time.The detection process of keep-alive time be with one it is initial when
Length detects the keep-alive time as initial detection duration, and detection duration is gradually increased in detection process, until most
The keep-alive time is determined eventually.And duration is detected it is to be understood that maintaining the electronic equipment and clothes during detecting the keep-alive time
Under the premise of connection between business device does not turn off, duration that the connection that current time is determined may maintain.
Optionally, it is contemplated that during detecting the keep-alive time, it can be generally stepped up the duration for sending keep-alive request,
Therefore, duration is detected it can be appreciated that sending the interval duration of keep-alive request before current time twice recently.
For the ease of distinguishing, which is got from the second electronic equipment in local area network, this second
Detection duration used in the electronic equipment detection keep-alive time is known as the first detection duration.
It is understood that when although any one the second electronic equipment does not detect keep-alive in current time local area network
Between, but the second electronic equipment is but likely to be at during detecting the keep-alive time.And due to the detection process of keep-alive time
It is the process for gradually increasing detection duration, therefore, if the first electronic equipment gets the second electronic equipment and currently detects the guarantor
Detection duration used in live time, so that it may based on continuing based on the currently used detection duration of second electronic equipment
The detection of keep-alive time without detecting the keep-alive time again since initial duration again, and then advantageously reduces detection keep-alive
Resource spent by time.
The benefit of the embodiment of the present application in order to facilitate understanding is below introduced the detection process of keep-alive time.Referring to
Fig. 3, it illustrates the detection process schematic diagrames of keep-alive time, after electronic equipment and server establish connection, the electronics
Equipment can be with following steps to the detection process of keep-alive time:
301, determine detection initial duration and incremental step-length used, and using the initial duration as initial detection
Duration;
Wherein it is determined that during the used initial duration of detection can be with the existing detection keep-alive time, when determining initial
Long mode is identical, as the initial duration can be a preset lesser duration.
302, the object time that should be reached after the detection duration currently determined from current time is determined, by this
At the time of object time is determined as that keep-alive request should be sent after current time next time;
The process of the object time is determined in order to facilitate understanding, is introduced with an example, for detecting for the first time, then
Currently initial duration when determining detection in a length of step 301, it is assumed that a length of 0.1 second when this is initial, current time is 1: 0
Divide 00 second, that is, 1:00:00, then it is current time that the object time that keep-alive is requested should be sent next time by, which speculating from current time,
At the time of corresponding to 0.10 second later.I.e. object time is 1: 10 second, i.e. 1:00:10.
303, keep-alive request is sent to server in the object time.
304, detect whether keep-alive request sends success, if so, thening follow the steps 305;If it is not, then entering step
306;
305, using current detection duration plus the resulting duration of preset step-length as updated detection duration, and return
Return step 302;
Wherein, the step-length can be understood as loop detection excessively in, every time needed for increased time span.For example, step-length can
Think 0.01 second etc..
If keep-alive request, which is sent, successfully illustrates that the connection between electronic equipment and server is not interrupted yet, in order to true
The maximum time that the fixed connection can maintain then can increase the step-length on the basis of currently detection duration, next to obtain
Secondary detection duration used.
For example, be still introduced with the example in step 302, if it is a length of initial when detection used in the last detection
Duration 0.1s, and step-length is 0.01 second, then detect+0.01 second 0.1 second a length of when detection used next time, i.e., detects next time
Shi Changwei 0.11 second.Correspondingly, after return step 302, determine the object time should with it is current at the time of with the update should
Detection duration 0.11 second, to determine object time.
306, judge to repeat to send whether the number of keep-alive request is more than preset times, if it is, entering step 307;
If it is not, then return step 303;
Wherein, which can be set as needed.In this detection process, if keep-alive request can not send
In the case where function, the purpose for repeating to send keep-alive request is in order to avoid appearing in the connection between server and electronic equipment not
When interruption, the case where judging by accident is generated since other reasons make keep-alive request send unsuccessful.
307, using the duration difference of current detection duration and the step-length as the keep-alive time determined.
If in this detection process, continuously repeat repeatedly send keep-alive request it is failed, then explanation visited currently
It surveys detection duration used and has been over the maximum time that the connection can maintain, which has interrupted, and upper primary
Detection duration employed in detection process is then less than the keep-alive time, so that current detection duration is subtracted the step-length
To obtain the keep-alive time.
For example, it is assumed that it is 0.15 second a length of when detection used in last detection, and in the secondary detection process, keep-alive request
Success can be sent, to illustrate the keep-alive time not less than the detection duration 0.15 second, in this way, when detection used in this detection
A length of 0.15 second was 0.16 second plus step-length 0.01 second, and it is success that this, which continuously transmits multiple keep-alive request, then illustrates to protect
Live time can subtract the step-length for 0.16 and obtain detection duration 0.15 second used in the last time less than 0.16 second, and should
It is determined as within 0.15 second connecting the maximum time that can be maintained, i.e. keep-alive time between electronic equipment and server.
It should be noted that the process of detection keep-alive time is it can be appreciated that the NAT to router in link is arranged above
The process that the ageing time of table is detected.
It is understood that Fig. 3, which is intended merely to facilitate, understands that the second electronic equipment detects keep-alive in the embodiment of the present application
The process of time and the concept for detecting duration, and a kind of mode of detection keep-alive time is described, it is actually existing
There are also other much by way of the keep-alive time, no matter which kind of mode to detect the keep-alive time by, detection process is one
Multiple cyclic process, and the detection duration of the embodiment of the present application can be to detect duration used in any detection process.
Below with reference to the process for detecting the keep-alive time shown in Fig. 3, to the first electronic equipment in the embodiment of the present application from second
The detection event that electronic equipment obtains the keep-alive time is introduced.
In the present embodiment, the second electronic equipment can carry out the detection of keep-alive time in the manner shown in fig. 3, it is assumed that the
For two electronic equipments during detecting the keep-alive time, the local area network is added in the first electronic equipment, and by into local area network
Broadcast message is sent, to obtain other interior electronic equipments of local area network to the detection event of keep-alive time.Second electronic equipment connects
After receiving the broadcast message, detection duration used in the last detection keep-alive time is determined, and the detection duration is sent to
First electronic equipment.After then first electronic equipment receives the detection duration, the detection duration can be directly based upon to keep-alive
Time is detected.For example, still by taking step-length is 0.01 second as an example, it is assumed that the second electronic equipment is receiving first electronic equipment
The keep-alive time when, the last time send keep-alive request at the time of be according to detection when deduce within a length of 0.15 second come the moment, then
0.15 second a length of when the detection of the determining current detection keep-alive request of second electronic equipment, then the first electronic equipment is in the detection
On the basis of 0.15 second long, continue the detection of subsequent keep-alive time, specifically, can add detecting duration 0.15 second
The step-length 0.01 second obtains first electronic equipment and currently detects when detection corresponding to the keep-alive time a length of 0.16 second, in turn
At the time of determining that current time should reach through the detection duration, and the moment send keep-alive request, then according to Fig. 3 according to
The step-length updates the detection duration, at the time of then redefining transmission keep-alive request using updated detection duration, so
Circulation, until finally determining the keep-alive time.It can be seen that the first electronic equipment is without repeating the second electronic equipment current
Detection steps before determining detection duration, it is possible to reduce the first electronic equipment sends the number of keep-alive request, and then improves
Resource consumption.
It should be noted that while the first electronic equipment is based on the detection duration detection keep-alive time, the second electronics
Equipment can equally continue to detect the keep-alive time, without restriction herein.
Optionally, in Fig. 2 embodiment, based on this first detection duration, detect this first connection keep-alive time it
Before, which can establish the first connection with given server, may then based on the first detection duration, to this
The keep-alive time of first connection is detected.
It is understood that due to the quantity of the second electronic equipment in local area network might have it is multiple, and this multiple second
The movement that electronic equipment detects the keep-alive time is simultaneously asynchronous, in this way, the first electronic equipment is possible to get multiple and different the
One detection duration, this first multiple and different detection duration is respectively used in different the second electronic equipment detection keep-alive time
Detect duration.And the first longer explanation of detection duration first detection duration is closer to the practical duration of keep-alive time, it can also be with
It is more to illustrate that the second electronic equipment sends the number that keep-alive is requested.Therefore, optionally, guarantor is sent in order to reduce by the first electronic equipment
The number of request living, when which can determine the longest maximum probe of duration from this multiple first detections duration
It is long, and it is directly based upon the maximum probe duration, detect the keep-alive time of first connection.
Optionally, it is contemplated that the no detection for the electronic equipment progress keep-alive time being newly connected in local area network is with the local
In netting based on the currently used detection duration of added electronic equipment, therefore, it is eventually adding the electronic equipment of local area network
The detection duration that current time carries out the detection of keep-alive time, which will not generally be less than, detects duration used by other electronic equipments.Cause
This, the first electronic equipment can show to get the second electronic equipment of setting in the local area network in detection result and currently detect this
Used by the keep-alive time of second connection when the first detection duration, based on the first detection duration, first connection is detected
The keep-alive time.Wherein, this set the second electronic equipment as before first electronic equipment the last time be connected to the local area network
The second electronic equipment.
Optionally, similar with the keep-alive time that the first electronic equipment is connect from the second electronic equipment acquisition second, first
Electronic equipment was based on the basis of the first detection duration detection keep-alive time, if the first electronic equipment detects the first connection
The keep-alive time, then the first keep-alive time connected can be equally sent to the second electricity in local area network by first electronic equipment
Sub- equipment, such second electronic equipment then can directly as second electronic equipment and refer to the first keep-alive time connected
The keep-alive time for determining the second connection between server, the detection keep-alive time is repeated without the second electronic equipment, is reduced
The resource cost of second electronic equipment.
Wherein, the first electronic equipment can use the mode that the keep-alive time of the first connection is sent to the second electronic equipment
The mode of broadcast.
Correspondingly, the first keep-alive time connected is broadcast to the other equipment in local area network in the first electronic equipment
When, if third electronic equipment is connected to the local area network just, which equally can directly first connect this
Keep-alive time of the keep-alive time connect as the third connection between the third electronic equipment and the given server, without again
Detect the keep-alive time.
Optionally, local area network is added with the first electronic equipment and is based on the first detection duration detection keep-alive in the first electronic equipment
On the basis of time, before the keep-alive time for detecting first connection, if detecting the third electronic equipment is connected to office
Domain net, then the first electronic equipment determines the second detection duration used in the keep-alive time for currently detecting first connection;By this
Two detection durations are sent to the third electronic equipment, so that the third electronic equipment is based on the second detection duration, to third
The keep-alive time of third connection between electronic equipment and given server is detected.
For example, the third electronic equipment for being newly connected to local area network sends to local area network and broadcasts the message, third electronics is set
The standby message informing that local area network is added is to other electronic equipments in local area network either to obtain detection event, then the first electronics is set
It is standby to detect that the third electronic equipment is connected to local area network.
Certainly, third electronic equipment is based on the second detection duration, the mistake detected to the keep-alive time of third connection
Journey can be similar based on the first detection duration detection process of keep-alive time to the first electronic equipment in preceding embodiment, herein not
It repeats again.
On the other hand, the embodiment of the present application also provides for supporting the above keep-alive time to determine the electronic equipment of method.
Referring to fig. 4, it illustrates the structural schematic diagram of the application a kind of electronic equipment one embodiment, the electricity of the present embodiment
Sub- equipment includes: processor 401 and memory 402.
Wherein, processor 401, for carrying out predetermined registration operation, being operated when the electronic equipment is connected to local area network
As a result;When the operating result shows that first electronic equipment gets second from the second electronic equipment in the local area network
When the keep-alive time of connection, it is determined that the keep-alive time of the first connection between the electronic equipment and given server is described
The keep-alive time of second connection, wherein the keep-alive time of second connection is second electronic equipment and the specified clothes
In the case that second between business device is connected to no data transmission, described second connects the maximum time that can be maintained;Wherein, institute
The second electronic equipment is stated different from the electronic equipment;
Memory 402, for data needed for storing the processor operation.
Certainly, electronic equipment can also include radio-frequency module, the connection processor and communication bus of memory etc..
Optionally, the electronic equipment further include:
Receiver, for receiving the broadcast message of the transmission of at least one second electronic equipment in the local area network;
Correspondingly, processor, specifically for detecting in the local area network when the electronic equipment is connected to local area network
The broadcast message that at least one second electronic equipment is sent obtains testing result;When the testing result shows the receiver
Receive the broadcast message, and when the broadcast message carries the keep-alive time of second connection, it is determined that the electricity
The keep-alive time of the first connection between sub- equipment and given server is the keep-alive time of second connection.
Optionally, the electronic equipment further include:
Transmitter, for sending broadcast message in the local area network, the broadcast message connects for requesting described second
The keep-alive time connect;
Receiver is directed to what the broadcast message returned for obtaining at least one second electronic equipment in the local area network
Response message;
Correspondingly, processor, specifically for when electronic equipment is connected to local area network, triggering described in the transmitter transmission
Broadcast message;It when detecting that the receiver receives the response message, and include described second connecting in the response message
When the keep-alive time connect, it is determined that the keep-alive time of the first connection between the electronic equipment and given server is described the
The keep-alive time of two connections.
Optionally, in any of the above one embodiment, the processor is also used to show not obtain when the operating result
When getting the keep-alive time of second connection, second electronic equipment is obtained currently to the keep-alive time of second connection
Detection event;When the detection event shows that getting second electronic equipment currently detects the keep-alive of second connection
Between used by first detection duration when, based on it is described first detection duration, detect it is described first connection the keep-alive time.
Optionally, described in the processor shows that getting second electronic equipment currently detects when the detection event
Used by the keep-alive time of second connection when the first detection duration, based on the first detection duration, detects described first and connect
The keep-alive time connect, specifically:
When the detection event shows that getting at least two second electronic equipments currently detects the described second guarantor connected
Used by live time when the first detection duration, the first detection duration used by least two second electronic equipment
In, determine maximum probe duration;Based on the maximum probe duration, the keep-alive time of first connection is detected.
Optionally, described in the processor shows that getting second electronic equipment currently detects when the detection event
Used by the keep-alive time of second connection when the first detection duration, based on the first detection duration, detects described first and connect
The keep-alive time connect, specifically:
Described is currently detected when the detection result shows to get the second electronic equipment of setting in the local area network
Used by the keep-alive time of two connections when the first detection duration, based on the first detection duration, first connection is detected
The keep-alive time, it is described to set the second electronic equipment and be connected to the local area network to be the last before the electronic equipment
Second electronic equipment.
Optionally, on the basis of above embodiments, the processor is also used to, in the guarantor for detecting first connection
After live time, the keep-alive time that described first connects is sent to the second electronic equipment in the local area network, so that institute
State keep-alive time that the second electronic equipment is connected described first as second electronic equipment and the given server it
Between second connection the keep-alive time.
Optionally, the processor is also used to, before the keep-alive time for detecting first connection, when detecting the
When three electronic equipments are connected to the local area network, the second detection used in the keep-alive time for currently detecting first connection is determined
Duration;The second detection duration is sent to the third electronic equipment, so that the third electronic equipment is based on described
Second detection duration visits the keep-alive time of the third connection between the third electronic equipment and the given server
It surveys.
For the embodiment of electronic equipment, since it essentially corresponds to embodiment of the method, so related place referring to
The part of embodiment of the method illustrates.The apparatus embodiments described above are merely exemplary, wherein described be used as is divided
Unit from part description may or may not be physically separated, component shown as a unit can be or
It may not be physical unit, it can it is in one place, or may be distributed over multiple network units.It can basis
It is actual to need that some or all of the modules therein is selected to achieve the purpose of the solution of this embodiment.Ordinary skill people
Member can understand and implement without creative efforts.
In several embodiments provided by the present invention, it should be understood that disclosed electronic equipment and method is not having
More than in spirit and scope, can realize in other way.Current embodiment is a kind of exemplary
Example should not be taken as limiting, and given particular content should in no way limit the purpose of the application.In addition, described system and
The schematic diagram of method and different embodiment, in without departing from scope of the present application, can with other systems, module, technology or
Method is combined or is integrated.Another point, shown or discussed mutual coupling, direct-coupling or communication connection can be
Through some interfaces, the indirect coupling or communication connection of device or unit can be electrical property, mechanical or other forms.
The above is only a specific embodiment of the invention, it is noted that for the ordinary skill people of the art
For member, various improvements and modifications may be made without departing from the principle of the present invention, these improvements and modifications are also answered
It is considered as protection scope of the present invention.
Claims (16)
1. a kind of keep-alive time determines method, comprising:
When the first electronic equipment is connected to local area network, predetermined registration operation is carried out based on the broadcast message in local area network, is operated
As a result;
When the operating result shows that first electronic equipment gets second from the second electronic equipment in the local area network
When the keep-alive time of connection, it is determined that between first electronic equipment and given server first connection the keep-alive time be
The keep-alive time of second connection, wherein the keep-alive time of second connection is second electronic equipment and the finger
Determine second between server be connected to no data transmission in the case where, the maximum time that can maintain of the second connection;Its
In, second electronic equipment is different from first electronic equipment.
2. the method according to claim 1, wherein the carry out predetermined registration operation, obtains operating result, comprising:
The broadcast message that at least one second electronic equipment in the local area network is sent is detected, testing result is obtained;
Then the operating result shows that first electronic equipment gets second from the second electronic equipment in the local area network
The keep-alive time of connection, comprising:
Testing result shows to detect the broadcast message, and when the broadcast message carries the keep-alive of second connection
Between.
3. the method according to claim 1, wherein the carry out predetermined registration operation, obtains operating result, comprising:
Broadcast message is sent in the local area network, the broadcast message is for requesting the keep-alive time of second connection;
Obtain the response message that at least one second electronic equipment is returned for the broadcast message in the local area network;
Then the operating result shows that first electronic equipment gets second from the second electronic equipment in the local area network
The keep-alive time of connection, comprising:
It include the keep-alive time of second connection in the response message.
4. the method according to claim 1, wherein further include:
When the operating result shows that the keep-alive time of second connection has not been obtained, obtains second electronic equipment and work as
The detection event of the preceding keep-alive time to second connection;
When the detection event shows that getting second electronic equipment currently detects the described second keep-alive time institute connected
When the first detection duration used, based on the first detection duration, the keep-alive time of first connection is detected.
5. according to the method described in claim 4, it is characterized in that, described when the detection event shows to get described second
When the first detection duration used by the keep-alive time that electronic equipment currently detects second connection, based on first detection
Duration detects the keep-alive time of first connection, comprising:
When the detection event shows that getting at least two second electronic equipments currently detects the keep-alive of second connection
Between used by first detection duration when, from used by least two second electronic equipment first detection duration in, really
Determine maximum probe duration;
Based on the maximum probe duration, the keep-alive time of first connection is detected.
6. according to the method described in claim 4, it is characterized in that, described when the detection event shows to get described second
When the first detection duration used by the keep-alive time that electronic equipment currently detects second connection, based on first detection
Duration detects the keep-alive time of first connection, comprising:
Second company is currently detected when the detection event shows to get the second electronic equipment of setting in the local area network
Used by the keep-alive time connect when the first detection duration, based on the first detection duration, the guarantor of first connection is detected
Live time, it is described to set the second electronic equipment and be connected to the local area network to be the last before first electronic equipment
Second electronic equipment.
7. according to the described in any item methods of claim 4-6, which is characterized in that when detecting the keep-alive of first connection
Between after, further includes:
The keep-alive time that described first connects is sent to the second electronic equipment in the local area network, so that second electricity
The keep-alive time that sub- equipment is connected described first is as second between second electronic equipment and the given server
The keep-alive time of connection.
8. according to the described in any item methods of claim 4-6, which is characterized in that when detecting the keep-alive of first connection
Between before, further includes:
When detecting that third electronic equipment is connected to the local area network, the keep-alive time for currently detecting first connection is determined
Second detection duration used;
The second detection duration is sent to the third electronic equipment, so that the third electronic equipment is based on described the
Two detection durations visit the keep-alive time of the third connection between the third electronic equipment and the given server
It surveys.
9. a kind of electronic equipment, comprising:
Processor, for carrying out default behaviour based on the broadcast message in local area network when the electronic equipment is connected to local area network
Make, obtains operating result;When the operating result shows that the electronic equipment is obtained from the second electronic equipment in the local area network
When getting the keep-alive time of the second connection, it is determined that when the keep-alive of the first connection between the electronic equipment and given server
Between be it is described second connection the keep-alive time, wherein it is described second connection the keep-alive time be second electronic equipment and institute
State second between given server be connected to no data transmission in the case where, it is described second connection can maintain maximum when
It is long;Wherein, second electronic equipment is different from the electronic equipment;
Memory, for data needed for storing the processor operation.
10. electronic equipment according to claim 9, which is characterized in that further include: receiver, for receiving the local
The broadcast message that at least one second electronic equipment in net is sent;
Then, processor, specifically for detecting at least one in the local area network when the electronic equipment is connected to local area network
The broadcast message that second electronic equipment is sent obtains testing result;When the testing result shows that the receiver receives institute
State broadcast message, and when the broadcast message carries the keep-alive time of second connection, it is determined that the electronic equipment with
The keep-alive time of the first connection between given server is the keep-alive time of second connection.
11. electronic equipment according to claim 9, which is characterized in that further include:
Transmitter, for sending broadcast message in the local area network, the broadcast message is for requesting second connection
The keep-alive time;
Receiver, for obtaining the response that at least one second electronic equipment is returned for the broadcast message in the local area network
Message;
Then, the processor, specifically for when the electronic equipment is connected to local area network, triggering described in the transmitter transmission
Broadcast message;It when detecting that the receiver receives the response message, and include described second connecting in the response message
When the keep-alive time connect, it is determined that the keep-alive time of the first connection between the electronic equipment and given server is described the
The keep-alive time of two connections.
12. electronic equipment according to claim 9, which is characterized in that
The processor is also used to obtain when the operating result shows that the keep-alive time of second connection has not been obtained
Second electronic equipment is currently to the detection event of the keep-alive time of second connection;The detection event shows to get
When the first detection duration used by the keep-alive time that second electronic equipment currently detects second connection, based on described
First detection duration detects the keep-alive time of first connection.
13. electronic equipment according to claim 12, which is characterized in that the processor shows to obtain when the detection event
When getting the first detection duration used by the keep-alive time that second electronic equipment currently detects second connection, it is based on
The first detection duration detects the keep-alive time of first connection, specifically:
When the detection event shows that getting at least two second electronic equipments currently detects the keep-alive of second connection
Between used by first detection duration when, from used by least two second electronic equipment first detection duration in, really
Determine maximum probe duration;Based on the maximum probe duration, the keep-alive time of first connection is detected.
14. electronic equipment according to claim 12, which is characterized in that the processor shows to obtain when the detection event
When getting the first detection duration used by the keep-alive time that second electronic equipment currently detects second connection, it is based on
The first detection duration detects the keep-alive time of first connection, specifically:
Second company is currently detected when the detection event shows to get the second electronic equipment of setting in the local area network
Used by the keep-alive time connect when the first detection duration, based on the first detection duration, the guarantor of first connection is detected
Live time, it is described to set the second electronic equipment and be connected to the second of the local area network to be the last before the electronic equipment
Electronic equipment.
15. according to the described in any item electronic equipments of claim 9-14, which is characterized in that the processor is also used to, and is being visited
After the keep-alive time for measuring first connection, the keep-alive time that described first connects is sent in the local area network the
Two electronic equipments, so that the keep-alive time that second electronic equipment is connected described first is as second electronic equipment
Second between the given server keep-alive time connecting.
16. according to the described in any item electronic equipments of claim 9-14, which is characterized in that the processor is also used to, and is being visited
Before the keep-alive time for measuring first connection, when detecting that third electronic equipment is connected to the local area network, determination is worked as
Second detection duration used in the keep-alive time of preceding detection first connection;The second detection duration is sent to described the
Three electronic equipments, so that the third electronic equipment is based on the second detection duration, to the third electronic equipment and institute
The keep-alive time for stating the third connection between given server is detected.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201511021003.4A CN105554151B (en) | 2015-12-29 | 2015-12-29 | A kind of keep-alive time determines method and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201511021003.4A CN105554151B (en) | 2015-12-29 | 2015-12-29 | A kind of keep-alive time determines method and electronic equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN105554151A CN105554151A (en) | 2016-05-04 |
CN105554151B true CN105554151B (en) | 2019-01-15 |
Family
ID=55833083
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201511021003.4A Active CN105554151B (en) | 2015-12-29 | 2015-12-29 | A kind of keep-alive time determines method and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN105554151B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107872495B (en) * | 2016-09-28 | 2020-06-26 | 腾讯科技(深圳)有限公司 | Information processing method and terminal equipment |
CN106911810A (en) * | 2017-04-28 | 2017-06-30 | 杭州迪普科技股份有限公司 | A kind of interface interchange method and apparatus |
CN111309395B (en) * | 2020-02-10 | 2021-07-20 | 北京星选科技有限公司 | Object keep-alive method and device, electronic equipment and computer readable storage medium |
CN112637940B (en) * | 2020-12-31 | 2024-03-08 | 南京佑川网络技术有限公司 | Low-power-consumption equipment dormancy keep-alive system and method |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7453825B1 (en) * | 2004-12-13 | 2008-11-18 | Garrettcom, Inc. | Apparatus and methods for point-to-point links in robust networks |
CN102769883A (en) * | 2011-05-03 | 2012-11-07 | 中国移动通信集团公司 | Method and equipment for transmitting heartbeat data packet based on always online of TCP (Transmission Control Protocol) |
CN103684815A (en) * | 2012-09-03 | 2014-03-26 | 中国移动通信集团公司 | Keep-alive method, device and system for data transmission link |
CN104243719A (en) * | 2013-06-08 | 2014-12-24 | 中国移动通信集团公司 | Heartbeat period determining method, system and device for long connection in mobile communication network |
CN104426692A (en) * | 2013-08-26 | 2015-03-18 | 联想(北京)有限公司 | Information processing method, apparatus, and network server |
-
2015
- 2015-12-29 CN CN201511021003.4A patent/CN105554151B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7453825B1 (en) * | 2004-12-13 | 2008-11-18 | Garrettcom, Inc. | Apparatus and methods for point-to-point links in robust networks |
CN102769883A (en) * | 2011-05-03 | 2012-11-07 | 中国移动通信集团公司 | Method and equipment for transmitting heartbeat data packet based on always online of TCP (Transmission Control Protocol) |
CN103684815A (en) * | 2012-09-03 | 2014-03-26 | 中国移动通信集团公司 | Keep-alive method, device and system for data transmission link |
CN104243719A (en) * | 2013-06-08 | 2014-12-24 | 中国移动通信集团公司 | Heartbeat period determining method, system and device for long connection in mobile communication network |
CN104426692A (en) * | 2013-08-26 | 2015-03-18 | 联想(北京)有限公司 | Information processing method, apparatus, and network server |
Also Published As
Publication number | Publication date |
---|---|
CN105554151A (en) | 2016-05-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105554151B (en) | A kind of keep-alive time determines method and electronic equipment | |
CN105897947B (en) | The Network Access Method and device of mobile terminal | |
CN105472148B (en) | Method and device for binding home equipment by terminal | |
CN110162726A (en) | Loading method, device and the storage medium of page resource | |
CN103986502B (en) | Information processing method, electronic device and system | |
CN105357076B (en) | Network connectivty detection method and device between a kind of node | |
CN106550323A (en) | Method for determining the geographical position of equipment | |
CN104780183A (en) | Information sharing method, device and electronic device | |
CN109981360B (en) | Internet of things equipment site opening method, device and system and storage medium | |
CN107517138A (en) | Equipment detection method and device | |
CN103916400B (en) | A kind of user account management method and system | |
CN111263338A (en) | Network distribution method of Bluetooth Mesh network and related network distribution equipment and system | |
CN101686141A (en) | Method and equipment for synchronizing read states | |
CN104869123A (en) | Network access control method and server | |
CN106797329A (en) | Special-purpose terminal and its operating method for measuring the Internet wire quality | |
CN105531955B (en) | Utilize the Wireless Networking of flexibly orderly repeater | |
CN108900982A (en) | Data forwarding method and device | |
CN102546710A (en) | Method, system and server for logging in chat groups based on mobile terminal | |
CN104754601B (en) | A kind of concealed nodes detection method, network node and server | |
CN105049520B (en) | A kind of method for pushing and device of information | |
CN105208516B (en) | A kind of bluetooth page method and apparatus | |
CN104796388A (en) | Network equipment scanning method and system and related devices | |
CN106230726A (en) | The detection method of forward-path and device | |
CN107483329B (en) | Neighbor table item management method and device | |
CN109547515A (en) | A kind of service calling method and relevant device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |