Welcome, guest | Sign In | My Account | Store | Cart
from socket import *
import struct
import sys
import time

TIME1970 = 2208988800L      # Thanks to F.Lundh

client = socket( AF_INET, SOCK_DGRAM )
data = '\x1b' + 47 * '\0'
client.sendto( data, ( sys.argv[1], 123 ))
data, address = client.recvfrom( 1024 )
if data:
    print 'Response received from:', address
    t = struct.unpack( '!12I', data )[10]
    t -= TIME1970
    print '\tTime=%s' % time.ctime(t)

History

  • revision 2 (22 years ago)
  • previous revisions are not available