urcontrol/tests/socketreceivetest.py
2022-05-31 15:26:53 +02:00

34 lines
No EOL
652 B
Python

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)
client = None
while True:
try:
client, address = s.accept()
print("Connected to", address)
except socket.error:
pass
if client is not None:
try:
data = client.recv( 1024 ).decode( 'utf-8' )
if data:
splitdata=data.split(",")
print("Received :", repr(data))
print(splitdata)
except socket.error:
pass
s.close()