January 2019
Beginner to intermediate
776 pages
19h 58m
English
Synchronizing your time is crucial accounting task. While it is not ideal to depend on the time from the internet for mission-critical systems, the NTP time is sufficiently accurate for most of the computing requirements.
Listing 11.5 gives a simple NTP server connection test as follows:
#!/usr/bin/env python
# Python Network Programming Cookbook, Second Edition -- Chapter - 11
# This program is optimized for Python 2.7.12 and Python 3.5.2.
# It may run on any other version with/without modifications. import argparse import ntplib from time import ctime def main(address, v): c = ntplib.NTPClient() response = c.request(address, version=v) print("Response Offset: ", response.offset) print("Version: ", response.version) print("Response ...Read now
Unlock full access