A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-list/1999-September/003742.html below:

timesync with python?

timesync with python? timesync with python?Fredrik Lundh fredrik at pythonware.com
Thu Sep 9 08:01:50 EDT 1999
Holger Jannsen <holger at phoenix-edv.netzservice.de> wrote:
> But I also thought that someone has an idea about that before
> and did it likely better than me. So, do you know a weblink
> to a script which already nearly does what I need? Perhaps 
> directly with interrogation at port 37 NTP?

from the eff-bot archives:

import socket, time

HOST = "my.server"
PORT = 37

TIME1970 = 2208988800L # 1970-01-01 00:00:00

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(HOST, PORT)

b = s.recv(4)

t0 = ord(b[3]) + (ord(b[2])<<8) + (ord(b[1])<<16) + (ord(b[0])<<24L)
t1 = int(time.time()) + TIME1970

dt = int(t0 - t1)

print "delta is", dt, "seconds"



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4