文档介绍:C#获取服务器时间
Posted on 2009-12-16 13:17 Pagan 阅读(1052)评论(0)编辑收藏 田日代码
using System;
using ;
using the reply departed th e server for client.
///
/// RoundTripDelay - The time between the departure of request a nd arrival of reply.
///
/// LocalClockOffset 一 The offset of the local clock relative to the primary reference
/// source.
///
/// Initialize - Sets up data structure and prepares for connect
ion.
///
/// Connect - Connects to the time server and populates the data strueture.
///
/// IsResponseValid 一 Returns true if received data is valid and if comes from
/// a NTP-compliant time server.
///
/// ToString - Returns a string representation of the object.
///
///
/// Structure of the standard NTP header (as described in RFC 20
30)
/// 1 2 3
/// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
1
/// +—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+—+ _+_+_+_+
/// |LI | VN |Mode | Stratum | Poll | Precision
I
/// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+ _+_+_+_+
/// | Root Delay |
/// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+ _+_+_+_+
/// | Root Dispersion |
/// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+ _+_+_+_+
/// | Reference Identifier |
/// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+ _+_+_+_+
/// I I
/// | Reference Timestamp (64)
I
/// I I
/// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+ _+_+_+_+
/// I I
/// I Originate Timestamp (64)
/// I I
/// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+
/// | |
/// | Receive Timestamp (64) |
/// I I
/// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+
_+_+_+_+
/// I I
/// | Transmit Timestamp (64)
I
/// I I
/// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+
_+_+_+_+
/// I Key Identifier (optional) (32)
I
/// +_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+
_+_+_+_+
/// I I
/// I I
/// I Message