Newer
Older
import socket
import time
i = 1
UDP_IP = "127.0.0.1"
UDP_PORT = 5001
MESSAGE = "{}".format(i)
print("UDP target IP: %s" % UDP_IP)
print("UDP target port: %s" % UDP_PORT)
print("message: %s" % MESSAGE)
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
while True:
sock.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP, UDP_PORT))
i += 1
MESSAGE = "{}".format(i)
time.sleep(0.2)
# time.sleep(0.1)