Skip to content

Instantly share code, notes, and snippets.

@HavishNetla
Last active July 26, 2019 15:16
Show Gist options
  • Save HavishNetla/f8dad3d8fa3ec158654b7ba19cea60fa to your computer and use it in GitHub Desktop.
Save HavishNetla/f8dad3d8fa3ec158654b7ba19cea60fa to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import socket
import ast
from contextlib import closing
HOST = '127.0.0.1' # The server's hostname or IP address
PORT = 65432 # The port used by the server
#a = LargeMotor(OUTPUT_A)
#b = MediumMotor(OUTPUT_B)
#c = MediumMotor(OUTPUT_C)
#d = LargeMotor(OUTPUT_D)
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
#print(sock.connect_ex((HOST, PORT)))
sock.bind(("0.0.0.0", 65432))
while True:
try:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
orig = (data.decode("utf-8"))
print(orig)
except Exception as e:
print(e)
# a.on(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment