欢迎来到天天文库
浏览记录
ID:1534701
大小:57.00 KB
页数:15页
时间:2017-11-12
《c# 获取服务器时间》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C#获取服务器时间Postedon2009-12-1613:17Pagan阅读(1052)评论(0)编辑收藏 代码usingSystem;usingSystem.Net;usingSystem.Net.Sockets;namespaceSNTPTime{//Leapindicatorfieldvaluespublicenum_LeapIndicator{NoWarning,//0-NowarningLastMinute61,//1-Lastminutehas61secondsLastMinute59,//2-Lastminutehas59secondsAlarm//3
2、-Alarmcondition(clocknotsynchronized)}//Modefieldvaluespublicenum_Mode{SymmetricActive,//1-SymmetricactiveSymmetricPassive,//2-SymmetricpasiveClient,//3-ClientServer,//4-ServerBroadcast,//5-BroadcastUnknown//0,6,7-Reserved}//Stratumfieldvaluespublicenum_Stratum{Unspecified,//0-unspecifi
3、edorunavailablePrimaryReference,//1-primaryreference(e.g.radio-clock)SecondaryReference,//2-15-secondaryreference(viaNTPorSNTP)Reserved//16-255-reserved}//////SNTPTimeClient的摘要说明。//////Publicclassmembers://////LeapIndicator-Warnsofanimpendingleapsecondtobeinserted/deletedinthel
4、ast///minuteofthecurrentday.(Seethe_LeapIndicatorenum)//////VersionNumber-Versionnumberoftheprotocol(3or4).//////Mode-Returnsmode.(Seethe_Modeenum)//////Stratum-Stratumoftheclock.(Seethe_Stratumenum)//////PollInterval-Maximumintervalbetweensuccessivemessages.//////Precision-Precisionoft
5、heclock.//////RootDelay-Roundtriptimetotheprimaryreferencesource.//////RootDispersion-Nominalerrorrelativetotheprimaryreferencesource.//////ReferenceID-Referenceidentifier(eithera4characterstringoranIPaddress).//////ReferenceTimestamp-Thetimeatwhichtheclockwaslastsetorcorrected.//////Or
6、iginateTimestamp-Thetimeatwhichtherequestdepartedtheclientfortheserver.//////ReceiveTimestamp-Thetimeatwhichtherequestarrivedattheserver.//////TransmitTimestamp-Thetimeatwhichthereplydepartedtheserverforclient.//////RoundTripDelay-Thetimebetweenthedepartureofrequestandarrivalofreply.///
7、///LocalClockOffset-Theoffsetofthelocalclockrelativetotheprimaryreference///source.//////Initialize-Setsupdatastructureandpreparesforconnection.//////Connect-Connectstothetimeserverandpopulatesthedatastructure.//////IsResponseValid-Returnstrueifreceiveddataisvalidandifcomesfrom
此文档下载收益归作者所有