타임서버에서 시간 가져오기 in python
# coding: euckr import os import sys import socket, time BASE1970 = 2208988800L def get_timeserver(hostname): try: host = socket.gethostbyname(hostname) except socket.gaierror: print 'internet connection or dns error!' sys.exit(1) port = socket.getservbyname('time', 'tcp') conn = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: conn.connect((host,port)) except: print 'timeserver connect er..
Code snippets/Python
2008. 5. 1. 23:21