import socket
import struct


address = ('127.0.0.1', 31500)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

while True:
    msg = struct.pack('!B', 1)
    if not msg:
        break
    s.sendto(msg, address)

s.close()