CN110474702A - One kind being based on System Clock, and relies on the implementation method for the Time Service that server-side is automatically repaired - Google Patents
One kind being based on System Clock, and relies on the implementation method for the Time Service that server-side is automatically repaired Download PDFInfo
- Publication number
- CN110474702A CN110474702A CN201810441465.9A CN201810441465A CN110474702A CN 110474702 A CN110474702 A CN 110474702A CN 201810441465 A CN201810441465 A CN 201810441465A CN 110474702 A CN110474702 A CN 110474702A
- Authority
- CN
- China
- Prior art keywords
- time
- server
- client
- current
- systemclock
- 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.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04J—MULTIPLEX COMMUNICATION
- H04J3/00—Time-division multiplex systems
- H04J3/02—Details
- H04J3/06—Synchronising arrangements
- H04J3/0635—Clock or time synchronisation in a network
-
- 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/34—Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Computer And Data Communications (AREA)
- Electric Clocks (AREA)
Abstract
The present invention is the shortcoming in order to overcome client and time synchronization in the prior art, there is provided one kind can be independent of fiducial time, and the server-side for effectively reducing error be automatically repaired based on System Clock, and rely on the implementation method for the Time Service that server-side is automatically repaired.It is t1 that the method step, which includes the time of the customer side interface acquisition of calling server-side for the first time,;Server-side is t2 by SystemClock class acquisition current system starting up to current runing time simultaneously;It is t3 in the starting up for obtaining current system by SystemClock class to current runing time when client obtains current time;It calculates client current time t=t1+ (t3-t2), and calculates server-side current time T=t+x.
Description
Technical field
The present invention relates to Internet technical field more particularly to clients and server-side Time synchronization technique field.
Background technique
Computer safety field uses the time largely to do and communicate expired mark, server-side and client time error
It is small as far as possible, be conducive to software security problem caused by avoiding the occurrence of others' malicious attack.
Method more commonly used at present is exactly to be calculated most according to fiducial time using setTimeout or setInterval
New time, such problems are that the time precision of setTimeout and setInterval are relatively low, one minute big after tested
It can generally differ several seconds (also related to computer performance and the task of operation), such precision is to be unable to satisfy under certain demands
's.In addition to this, if to obtain the more accurately time can periodically be calibrated with server, be only realized at
This is larger.
Because the present invention provides a kind of energy at present it is desirable that reducing the time error between server-side and client
It is enough independent of fiducial time, and the implementation method of Time Service that the server-side for effectively reducing error is automatically repaired.
Summary of the invention
The present invention is the shortcoming in order to overcome client and time synchronization in the prior art, and providing one kind can not
Dependent on fiducial time, and the server-side for effectively reducing error be automatically repaired based on System Clock, and rely on clothes
The implementation method for the Time Service that business end is automatically repaired.
To achieve the above object, the invention adopts the following technical scheme:
One kind of the invention is based on System Clock, and relies on the realization side for the Time Service that server-side is automatically repaired
Method, characterized in that the described method comprises the following steps:
The time that customer side calls the interface of server-side to obtain for the first time is t1;
Server-side is t2 by SystemClock class acquisition current system starting up to current runing time simultaneously;
When client obtains current time, the starting up of current system is being obtained by SystemClock class to working as
Preceding runing time is t3;
It calculates client current time t=t1+ (t3-t2), and calculates server-side current time T=t+x.
Preferably, the x is that server-side is got and returns to client after the time and get to system SystemClock
As a result time, error is related with network, and in the good situation of network, x is about within 0.5s.
Preferably, further comprising the steps of after the step:
It, all can be with client time t, if server-side is sentenced in required parameter when client each request interface
Time of breaking has been more than the permitted time error range t4 of server-side, then judges that client time needs to correct.
Preferably, further comprising the steps of after the step:
If judging, client time needs to correct, and server can return to server-side current time T;
Client is modified local zone time according to server-side current time T.
Present invention simultaneously provides one kind to be based on System Clock, and relies on the Time Service that server-side is automatically repaired
Realization system, characterized in that the system comprises:
First logging modle is t1 for recording the time that customer side calls the interface of server-side to obtain for the first time;
First timing module, for while the interface of server-side is called for the first time in customer side, server-side to pass through
SystemClock class obtain current system starting up to current runing time be t2;
Second timing module, for obtaining current system by SystemClock class when client obtains current time
The starting up of system to current runing time be t3;
Computing module for calculating client current time t=t1+ (t3-t2), and calculates server-side current time T=t
+x。
Preferably, the x is that server-side is got and returns to client after the time and get to system SystemClock
As a result time, error is related with network, and in the good situation of network, x is about within 0.5s.
Preferably, the system also includes:
Judgment module, for when client each request interface, when all can be with client in required parameter
Between t, if server-side judges that the time has been more than the permitted time error range t4 of server-side, judge client time need
It corrects.
Preferably, the system also includes:
Correction module, if server can return to server-side current time T for judging that client time needs to correct;
Client is modified local zone time according to server-side current time T.
Technical solution of the present invention guarantees client and server-side time using the mechanism of SystemClock at Android end
It is synchronous.Client requests the error that verification local zone time can be all removed when service end interface every time, if error is more than certain
Range, with regard to timely correction local zone time.Because computer safety field uses the time largely to do and communicate expired mark, take
Business end and client time error are small as far as possible, are conducive to software security problem caused by avoiding the occurrence of others' malicious attack.
Detailed description of the invention
Fig. 1 is the first pass figure of method of the invention.
Specific embodiment
The present invention is described further with reference to the accompanying drawings and detailed description.
One kind of the invention is based on System Clock, and relies on the realization side for the Time Service that server-side is automatically repaired
Method, characterized in that the described method comprises the following steps:
The time that customer side calls the interface of server-side to obtain for the first time is t1;
Server-side is t2 by SystemClock class acquisition current system starting up to current runing time simultaneously;
When client obtains current time, the starting up of current system is being obtained by SystemClock class to working as
Preceding runing time is t3;
It calculates client current time t=t1+ (t3-t2), and calculates server-side current time T=t+x.
Preferably, the x is that server-side is got and returns to client after the time and get to system SystemClock
As a result time, error is related with network, and in the good situation of network, x is about within 0.5s.
Preferably, further comprising the steps of after the step:
It, all can be with client time t, if server-side is sentenced in required parameter when client each request interface
Time of breaking has been more than the permitted time error range t4 of server-side, then judges that client time needs to correct.
Preferably, further comprising the steps of after the step:
If judging, client time needs to correct, and server can return to server-side current time T;
Client is modified local zone time according to server-side current time T.
Present invention simultaneously provides one kind to be based on System Clock, and relies on the Time Service that server-side is automatically repaired
Realization system, characterized in that the system comprises:
First logging modle is t1 for recording the time that customer side calls the interface of server-side to obtain for the first time;
First timing module, for while the interface of server-side is called for the first time in customer side, server-side to pass through
SystemClock class obtain current system starting up to current runing time be t2;
Second timing module, for obtaining current system by SystemClock class when client obtains current time
The starting up of system to current runing time be t3;
Computing module for calculating client current time t=t1+ (t3-t2), and calculates server-side current time T=t
+x。
Preferably, the x is that server-side is got and returns to client after the time and get to system SystemClock
As a result time, error is related with network, and in the good situation of network, x is about within 0.5s.
Preferably, the system also includes:
Judgment module, for when client each request interface, when all can be with client in required parameter
Between t, if server-side judges that the time has been more than the permitted time error range t4 of server-side, judge client time need
It corrects.
Preferably, the system also includes:
Correction module, if server can return to server-side current time T for judging that client time needs to correct;
Client is modified local zone time according to server-side current time T.
Technical solution of the present invention guarantees client and server-side time using the mechanism of SystemClock at Android end
It is synchronous.Client requests the error that verification local zone time can be all removed when service end interface every time, if error is more than certain
Range, with regard to timely correction local zone time.Because computer safety field uses the time largely to do and communicate expired mark, take
Business end and client time error are small as far as possible, are conducive to software security problem caused by avoiding the occurrence of others' malicious attack.
Claims (8)
1. one kind is based on System Clock, and relies on the implementation method for the Time Service that server-side is automatically repaired, feature
It is that the described method comprises the following steps:
The time that customer side calls the interface of server-side to obtain for the first time is t1;
Server-side is t2 by SystemClock class acquisition current system starting up to current runing time simultaneously;
When client obtain current time when, by SystemClock class obtain current system starting up to currently
Runing time is t3;
It calculates client current time t=t1+ (t3-t2), and calculates server-side current time T=t+x.
2. according to the method described in claim 1, it is characterized in that, the x is that server-side is got and returns to client after the time
The time of result is got to system SystemClock, error is related with network, and in the good situation of network, x is about
Within 0.5s.
3. according to the method described in claim 1, it is characterized in that, it is further comprising the steps of after the step:
It, all can be with client time t, if server-side judgement should in required parameter when client each request interface
Time has been more than the permitted time error range t4 of server-side, then judges that client time needs to correct.
4. according to the method described in claim 1, it is characterized in that, it is further comprising the steps of after the step:
If judging, client time needs to correct, and server can return to server-side current time T;
Client is modified local zone time according to server-side current time T.
5. one kind is based on System Clock, and relies on the realization system for the Time Service that server-side is automatically repaired, feature
It is, the system comprises:
First logging modle is t1 for recording the time that customer side calls the interface of server-side to obtain for the first time;
First timing module, for while the interface of server-side is called for the first time in customer side, server-side to pass through
SystemClock class obtain current system starting up to current runing time be t2;
Second timing module, for obtaining current system by SystemClock class when client obtains current time
Starting up to current runing time be t3;
Computing module for calculating client current time t=t1+ (t3-t2), and calculates server-side current time T=t+x.
6. system according to claim 5, characterized in that the x is to return to client after server-side gets the time
The time of result is got to system SystemClock, error is related with network, and in the good situation of network, x is about
Within 0.5s.
7. system according to claim 5, characterized in that the system also includes:
Judgment module, for when client each request interface, in required parameter all can with client time t,
If server-side judges that the time has been more than the permitted time error range t4 of server-side, judge that client time needs to repair
Just.
8. system according to claim 5, characterized in that the system also includes:
Correction module, if server can return to server-side current time T for judging that client time needs to correct;Client
End is modified local zone time according to server-side current time T.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810441465.9A CN110474702A (en) | 2018-05-10 | 2018-05-10 | One kind being based on System Clock, and relies on the implementation method for the Time Service that server-side is automatically repaired |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810441465.9A CN110474702A (en) | 2018-05-10 | 2018-05-10 | One kind being based on System Clock, and relies on the implementation method for the Time Service that server-side is automatically repaired |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110474702A true CN110474702A (en) | 2019-11-19 |
Family
ID=68503746
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810441465.9A Pending CN110474702A (en) | 2018-05-10 | 2018-05-10 | One kind being based on System Clock, and relies on the implementation method for the Time Service that server-side is automatically repaired |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110474702A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110838885A (en) * | 2019-11-20 | 2020-02-25 | 金蝶软件(中国)有限公司 | System time synchronization method and related device |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101060425A (en) * | 2006-04-21 | 2007-10-24 | 大唐移动通信设备有限公司 | Absolute time data acquiring method and system |
CN101399657A (en) * | 2007-09-26 | 2009-04-01 | Vega格里沙贝两合公司 | Method for the automatic time synchronisation of devices in network-based systems |
CN107046600A (en) * | 2017-03-09 | 2017-08-15 | 广东艾檬电子科技有限公司 | A kind of determination method and device of android system standard time |
US10574375B2 (en) * | 2015-03-04 | 2020-02-25 | Sony Corporation | Transmission device, transmission method, reception device, and reception method |
-
2018
- 2018-05-10 CN CN201810441465.9A patent/CN110474702A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101060425A (en) * | 2006-04-21 | 2007-10-24 | 大唐移动通信设备有限公司 | Absolute time data acquiring method and system |
CN101399657A (en) * | 2007-09-26 | 2009-04-01 | Vega格里沙贝两合公司 | Method for the automatic time synchronisation of devices in network-based systems |
US10574375B2 (en) * | 2015-03-04 | 2020-02-25 | Sony Corporation | Transmission device, transmission method, reception device, and reception method |
CN107046600A (en) * | 2017-03-09 | 2017-08-15 | 广东艾檬电子科技有限公司 | A kind of determination method and device of android system standard time |
Non-Patent Citations (1)
Title |
---|
BLUESTORM: "System.currentTimeMills()与SystemClock.uptimeMills()", 《博客园》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110838885A (en) * | 2019-11-20 | 2020-02-25 | 金蝶软件(中国)有限公司 | System time synchronization method and related device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2017024688A1 (en) | Control method and system capable of system upgrade without interrupting services | |
US7475272B2 (en) | Method for calculating clock offset and skew | |
JP4347082B2 (en) | Time correction device, time correction method, and time correction program for event trace data | |
CN107609188B (en) | Data synchronization verification method based on golden gate | |
CN102970181A (en) | Monitoring system and monitoring method of self-service terminal states | |
JP2020526051A (en) | Method, computer readable medium, system for verifying time functions of masters and clients in a vehicle network, and vehicle having this system | |
ATE415661T1 (en) | METHOD FOR IMPROVING THE AVAILABILITY OF A COMPUTER CLUSTERING SYSTEM BY USING A NETWORK-MEDIA LINK STATE FUNCTION | |
CN106301953B (en) | Distributed fault-tolerant clock synchronous method and system suitable for time trigger Ethernet | |
CN110061797A (en) | Method for synchronizing time, device, storage medium and computer equipment | |
CN112738294B (en) | Domain name resolution method and device based on block chain, electronic equipment and storage medium | |
CN105183672B (en) | A kind of adaptive interface call method and system | |
CN112671950B (en) | Domain name processing method and device based on block chain, electronic equipment and storage medium | |
CN111211934B (en) | Cluster remote communication test method and system | |
CN111294135A (en) | Edge cloud-oriented multi-stage clock synchronization method | |
CN104991831A (en) | SSO system integration method based on server | |
CN110442591B (en) | Global clock system and method of alliance chain | |
EP4231220A3 (en) | Method, program, and system for providing virtual corporate card-based financial transaction | |
CN107316176A (en) | The control method and device of declaration form processing | |
CN110474702A (en) | One kind being based on System Clock, and relies on the implementation method for the Time Service that server-side is automatically repaired | |
CN108932007B (en) | Method for acquiring time stamp and computer device | |
CN106712889B (en) | A kind of time service device, method and system | |
CN107547160B (en) | A kind of method for synchronizing time and device | |
KR101191832B1 (en) | Database Replication Method And System Using Analyzing Network Packets | |
US11263112B2 (en) | Method and apparatus for evaluating quality of software running environment of device | |
CN112769517A (en) | T-BOX time synchronization method and device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20191119 |
|
RJ01 | Rejection of invention patent application after publication |