diff --git a/UdpListener.py b/UdpListener.py new file mode 100644 index 0000000..3ea4f51 --- /dev/null +++ b/UdpListener.py @@ -0,0 +1,13 @@ +import socket + +def start_server(ip, port): + server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + server_socket.bind((ip, port)) + print(f"UDP server listening on {ip}:{port}") + + while True: + data, addr = server_socket.recvfrom(1024) # buffer size is 1024 bytes + print(f"received message: {data} from {addr}") + +if __name__ == "__main__": + start_server("localhost", 8888) diff --git a/UdpMocker.py b/UdpMocker.py index 5909312..f70d683 100644 --- a/UdpMocker.py +++ b/UdpMocker.py @@ -3,7 +3,7 @@ import time # UDP Configuration ip = "localhost" # Change this to the IP address of your computer or the network address to multicast -port = 27019 # Ensure this matches the port number in your Unity script +port = 8888 # Ensure this matches the port number in your Unity script # Create the UDP socket sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)