Last active
October 17, 2024 12:39
-
-
Save gyillikci/54b876c0c46a4bdf35b594bb35fbeba2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import struct | |
UDP_IP = "127.0.0.1" | |
UDP_PORT = 60002 | |
BUFFER_SIZE = 1024 | |
# Create a UDP socket | |
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
sock.bind((UDP_IP, UDP_PORT)) | |
#print(f"listening on {host}:{port}") | |
while True: | |
# Receive data | |
data, addr = sock.recvfrom(BUFFER_SIZE) | |
unpacked_floats = struct.unpack('ff', data) | |
print("Unpacked Floats:", unpacked_floats) | |
#print(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment