#! /usr/bin/python3 import socket import struct import sys import time dest = ("127.0.0.1", 5740) name = "name_H23_X42" pos = 0.0 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.connect(dest) flags = 0 name_b = name.encode("utf-8") while True: pos_ms = round(pos * 1000) data = b"PoSy" + struct.pack("!I64sI", flags, name_b, pos_ms) try: sock.send(data) except IOError: pass pos += 1.0 time.sleep(1) sock.close()