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
评论列表
文章目录