import time import socket import os, sys cudir,_ = os.path.split(__file__) file_folder = os.path.join(cudir,"demoData") packed_count = 0 if __name__ == '__main__': files = ["packet{}.udp".format(i) for i in range(0, 100)] for file in files: with open(os.path.join(file_folder,file), "rb") as f: message = f.read() client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) client_socket.settimeout(1.0) addr = ("127.0.0.1", 9911) client_socket.sendto(message, addr) print (time.asctime(), f' Sending {file} to {addr} ...') time.sleep(0.1) print('Done!')