RoboRally/remote_control/measurement_client.py

13 lines
326 B
Python
Raw Normal View History

import socket
HOST, PORT = "localhost", 42424
robot_id = 15
# SOCK_DGRAM is the socket type to use for UDP sockets
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(f"{robot_id}\n".encode(), (HOST, PORT))
while True:
received = str(sock.recv(1024), "utf-8")
print("Received: {}".format(received))