twitchyliquid64 Posted December 7, 2010 Share Posted December 7, 2010 (edited) Hi scripterz, Heres a neat little tool Ive written to allow you to recieve the internet time for either US Government or NIST servers. It uses the DAYTIME Protocol to interact with deddicated time servers. It is accurate to 0.030 of a second plus (roundtrip/2). Making it extremely accurate. Unlike some of the other Autoit scripts, it uses multiple sources and dedicated and continiously synchronized time servers, making it quite precise. I have no problems with people stealing the code for their proggies. expandcollapse popup;GET INTERNET TIME USING DAYTIME PROTOCOL (Developed in 1983 as part of the Internet Protocol Suite) ;WARNING--NEVER Query a server more than once every 4 seconds!!! you will be considered to be misconfigured and all ;future connections refused!!! ;Concept reference: ;1. Server randomly selected ;2. TCP Connection established ;3. Wait for data - if waiting for more then 3 seconds then timeout. ;4. Split data and process time/date in UTC format. ;5. Termination. ; All these servers use the NIST standard. dim $US_Govt_Servers[5] = ["68.216.79.113", "24.56.178.140", "132.163.4.101", "132.163.4.103", "131.107.13.100"] dim $Aux_servers[5] = ["64.90.182.55", "206.246.122.250", "173.14.47.149", "128.138.188.172", "64.147.116.229"] ;GOVT Servers Selection (comment out the one you dont want) $ip = $US_Govt_Servers[Random( 0, UBound( $US_Govt_Servers)-1, 1)] ConsoleWrite(@CRLF & "IP Selected (US Govt Server): " & $ip & @CRLF) ;Aux Servers Selection (comment out the one you dont want) ;$ip = $Aux_servers[Random( 0, UBound( $Aux_servers)-1, 1)] ;ConsoleWrite(@CRLF & "IP Selected (NIST Organisation Server): " & $ip & @CRLF) TCPStartup() $connection_socket = TCPConnect( $ip, 13) ;error checking if $connection_socket = -1 then ConsoleWriteError( "FAILURE: Unable to establish connection to server" & @CRLF) if $connection_socket = -1 then Exit $valid_timer = TimerInit() $recv_data = "" While TimerDiff( $valid_timer) < 3000 and $recv_data = "" $recv_data = TCPRecv( $connection_socket, 2000) WEnd if $recv_data = "" then ConsoleWriteError( "FAILURE: Request timed out" & @CRLF) if $recv_data = "" then Exit $space_split = StringSplit( $recv_data, " ") if $space_split[0] < 3 then ConsoleWriteError( "FAILURE: Unexpected data on socket!" & @CRLF) if $space_split[0] < 3 then Exit $year = $space_split[1] $date = $space_split[2] $time = $space_split[3] ConsoleWrite( $year & "||" & $date & " " & $time & @CRLF) MsgBox( 4096, "Internet Time: " & $year, $date & @CRLF & @CRLF & $time, 6) ;Return Data structure: JJJJJ YR-MO-DA HH:MM:SS TT L H msADV UTC(NIST) OTM EDIT: Got the subtitle wrong; should be 'from' several internet sources. Edited December 7, 2010 by hyperzap ongoing projects:-firestorm: Largescale P2P Social NetworkCompleted Autoit Programs/Scripts: Variable Pickler | Networked Streaming Audio (in pure autoIT) | firenet p2p web messenger | Proxy Checker | Dynamic Execute() Code Generator | P2P UDF | Graph Theory Proof of Concept - Breadth First search Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now