diff --git a/tests/socketreceivetest.py b/tests/socketreceivetest.py index 00be94d..afe9210 100644 --- a/tests/socketreceivetest.py +++ b/tests/socketreceivetest.py @@ -8,21 +8,27 @@ 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) - - data = client.recv( 1024 ).decode( 'utf-8' ) - splitdata=data.split(",") - - print("Received :", repr(data)) - print(splitdata) 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() \ No newline at end of file diff --git a/tests/socketsendtest.py b/tests/socketsendtest.py index cdee30e..11dd785 100644 --- a/tests/socketsendtest.py +++ b/tests/socketsendtest.py @@ -1,14 +1,16 @@ import socket - +import time TCP_IP = '127.0.0.1' TCP_PORT = 30002 -BUFFER_SIZE = 1024 message = "12.3,20.15" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) + + +time.sleep(1) s.send(message.encode('utf-8')) s.close()