欢迎来到天天文库
浏览记录
ID:10212434
大小:57.00 KB
页数:15页
时间:2018-06-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-Lastmin
2、utehas59secondsAlarm//3-Alarmcondition(clocknotsynchronized)}//Modefieldvaluespublicenum_Mode{SymmetricActive,//1-SymmetricactiveSymmetricPassive,//2-SymmetricpasiveClient,//3-ClientServer,//4-ServerBroadcast,//5-BroadcastUnknown//0,6,7-Reserved}//Stratumfieldvalu
3、espublicenum_Stratum{Unspecified,//0-unspecifiedorunavailablePrimaryReference,//1-primaryreference(e.g.radio-clock)SecondaryReference,//2-15-secondaryreference(viaNTPorSNTP)Reserved//16-255-reserved}//////SNTPTimeClient的摘要说明。//////Publicclassmembers://///
4、/LeapIndicator-Warnsofanimpendingleapsecondtobeinserted/deletedinthelast///minuteofthecurrentday.(Seethe_LeapIndicatorenum)//////VersionNumber-Versionnumberoftheprotocol(3or4).//////Mode-Returnsmode.(Seethe_Modeenum)//////Stratum-Stratumoftheclock.(Seethe_Stratume
5、num)//////PollInterval-Maximumintervalbetweensuccessivemessages.//////Precision-Precisionoftheclock.//////RootDelay-Roundtriptimetotheprimaryreferencesource.//////RootDispersion-Nominalerrorrelativetotheprimaryreferencesource.//////ReferenceID-Referenceidentifier(
6、eithera4characterstringoranIPaddress).//////ReferenceTimestamp-Thetimeatwhichtheclockwaslastsetorcorrected.//////OriginateTimestamp-Thetimeatwhichtherequestdepartedtheclientfortheserver.//////ReceiveTimestamp-Thetimeatwhichtherequestarrivedattheserver.//////Transm
7、itTimestamp-Thetimeatwhichthereplydepartedtheserverforclient.//////RoundTripDelay-Thetimebetweenthedepartureofrequestandarrivalofreply.//////LocalClockOffset-Theoffsetofthelocalclockrelativetotheprimaryreference///source.//////Initialize-Setsupdatastructureandprep
8、aresforconnection.//////Connect-Connectstothetimeserverandpopulatesthedatastructure.//////IsResponseValid-Returnstrueifreceiveddataisvalidandifcomesfrom
此文档下载收益归作者所有