xv6-lab/ping.py
Frans Kaashoek 7106151533 Lab net
2022-10-24 07:04:45 -04:00

13 lines
290 B
Python

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)