summaryrefslogtreecommitdiff
path: root/ping.py
blob: eab10f8d4db0e8accdcbf4aa39708ad574fb428c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import socket
import sys
import time

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
addr = ('localhost', int(sys.argv[1]))
buf = "this is a ping!".encode('utf-8')

while True:
	print("pinging...", file=sys.stderr)
	sock.sendto(buf, ("127.0.0.1", int(sys.argv[1])))
	time.sleep(1)