Skip to content

Instantly share code, notes, and snippets.

@gyillikci
Last active October 17, 2024 12:39
Show Gist options
  • Save gyillikci/54b876c0c46a4bdf35b594bb35fbeba2 to your computer and use it in GitHub Desktop.
Save gyillikci/54b876c0c46a4bdf35b594bb35fbeba2 to your computer and use it in GitHub Desktop.
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