urcontrol/tests/socketreceivetest.py

28 lines
493 B
Python
Raw Normal View History

2022-05-31 13:05:06 +00:00
import socket
import math
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host =""
port =30002
s.bind((host,port))
s.listen(1) # Number of connections
s.setblocking(False)
while True:
try:
client, address = s.accept()
print("Connected to", address)
data = client.recv( 1024 ).decode( 'utf-8' )
splitdata=data.split(",")
print("Received :", repr(data))
print(splitdata)
except socket.error:
pass
s.close()