胡紹波



摘 要: 目前很多軟件系統(tǒng)都是基于網(wǎng)絡(luò)環(huán)境的,擁有統(tǒng)一的時間是許多分布式軟件應(yīng)用的前提,但是這些軟件系統(tǒng)并沒有提供同步各計算機系統(tǒng)時間的功能。為此,探討了Windows環(huán)境下局域網(wǎng)系統(tǒng)時間同步的相關(guān)設(shè)計模型,介紹了系統(tǒng)的開發(fā)原理、設(shè)計思想和具體實現(xiàn),給出了主要的程序代碼。該系統(tǒng)的開發(fā),解決了實際工作中局域網(wǎng)計算機時間同步的問題,達到了預(yù)期的效果。
關(guān)鍵詞: 時間同步; 系統(tǒng)設(shè)計; 系統(tǒng)實現(xiàn); Socket
中圖分類號:TP3 文獻標志碼:B 文章編號:1006-8228(2013)06-45-02
Design and implementation of time-synchronization system for LAN
Hu Shaobo
(Kunming Branch of the People's Bank of China, Kunming, Yunnan 650021, China)
Abstract: Since many software systems are based on the network environment, a unified time is the premise of many distributed software applications. However these software usually do not provide the synchronization function of computer system time. Therefore, the design model of time-synchronization system for LAN based on Windows is discussed. The principles of system development and design ideas are introduced, and the main program code is given. The problem of the LAN computer time synchronization is overcome by development of the system in practice, which achieves the desired effects.
Key words: time-synchronization; system design; system implementation; Socket
0 引言
隨著計算機網(wǎng)絡(luò)應(yīng)用范圍的不斷擴大,對網(wǎng)絡(luò)設(shè)備及網(wǎng)絡(luò)應(yīng)用的時間同步提出了越來越高的要求,擁有一個精準的時間同步機制是許多分布式應(yīng)用的前提[1]。目前大部分軟件系統(tǒng)均是基于網(wǎng)絡(luò)環(huán)境的,但是相當數(shù)量的軟件系統(tǒng),并未具有與各計算機系統(tǒng)的時間同步功能,通常是利用操作系統(tǒng)的時間同步功能進行時間同步,步驟繁瑣[2]。如果人工修改各計算機時間,不但費時,而且很難做到精準。為此,開發(fā)一個能同步局域網(wǎng)內(nèi)各指定計算機時間的軟件系統(tǒng)是很有意義的。
1 系統(tǒng)功能
該系統(tǒng)的主要功能是以局域網(wǎng)中某一臺計算機(客戶端)的時間為基準,將局域網(wǎng)中計算機時間統(tǒng)一為該指定的計算機時間,從而實現(xiàn)局域網(wǎng)內(nèi)計算機時間的同步,保證其他應(yīng)用軟件數(shù)據(jù)采集的正確性。
1.1 系統(tǒng)用例圖
該系統(tǒng)的用例圖,如圖1所示。
[設(shè)置需同步時間的計算機網(wǎng)絡(luò)端口] [管理需同步時間的計算機網(wǎng)絡(luò)地址] [系統(tǒng)管理員][啟動系統(tǒng)時間同步服務(wù)] [同步系統(tǒng)時間]……p>