Ajax
ASP
C,C++
C#,.NET
CSS,HTML
Delphi,Kylix
Experience
Flash
Java
JavaScript
PHP
Python
QT
SQL
ShellScript
VB
U :
P :
Register
Lost Password
Other Links
Code Archive
Save Giovanni
C#,.NET Category Code
Real Name
:
SharingCode.NET User
Subject
:
NTP Sample Code
Description
:
Requirements:
Requires ASocket.dll to run the sample. Download it from http://www.vahland.com/asocket/asocket.dll
Comments:
NTP sample in VC#.NET, sowing how to retrieve date and time from a NTP time server
// ******************************************************************** // NTP Sample: retrieve time from NTP time server // // IMPORTANT: // Online manual: http://www.vahland.com/asocket/manual.htm // ******************************************************************** static void Main(string[] args) { Ntp objNtp = new NtpClass(); asConstants objConstants = new asConstants(); String strTimeserver = "fartein.ifi.uio.no"; Console.WriteLine( "Retrieving time from timeserver " + strTimeserver + "..." ); objNtp.GetTime( strTimeserver ); Console.WriteLine( "GetTime, result: " + objNtp.LastError + " (" + objNtp.GetErrorDescription( objNtp.LastError ) + ")" ); if( objNtp.LastError == objConstants.asERR_SUCCESS ) { Console.WriteLine( " Year: " + objNtp.Year.ToString() ); Console.WriteLine( " Month: " + objNtp.Month.ToString() ); Console.WriteLine( " Dat: " + objNtp.Day.ToString() ); Console.WriteLine( " Hour: " + objNtp.Hour.ToString() ); Console.WriteLine( " Minute: " + objNtp.Minute.ToString() ); Console.WriteLine( " Second: " + objNtp.Second.ToString() ); } Console.WriteLine( "Ready." ); System.Threading.Thread.Sleep(10000); }
Rating
:
0.00
(out of 5)
Visitor Voting Booth
:
Excellent
Very Good
Good
Fair
Poor
Copyright © 2006 SharingCode.NET . All rights reserved. Hosted By: SisNetworks