heart_beat.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pyDDNS 作者: ideamark 项目源码 文件源码
def heart_beat():
    count = 0
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    try:
        port = int(PORT)
    except ValueError:
        port = socket.getservbyname(PORT, 'udp')
    s.connect((HOST, port))
    s.settimeout(5)
    while True:
        try:
            s.sendall(b'#Hi')
            count += 1
            print('Send a heart beat', count)
            time.sleep(10)    # Set your heart beat delay
        except KeyboardInterrupt:
            sys.exit(1)
        except:
            continue
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号