Fix - Harmony - unable to change workfile

It was failing on Mac with OSError 9 Bad file descriptor and 48 Address already in use.
This commit is contained in:
Petr Kalis 2023-01-17 18:24:18 +01:00
parent 3e74a27efa
commit f686f74b7f

View file

@ -40,6 +40,7 @@ class Server(threading.Thread):
# Create a TCP/IP socket
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# Bind the socket to the port
server_address = ("127.0.0.1", port)
@ -91,7 +92,13 @@ class Server(threading.Thread):
self.log.info("wait ttt")
# Receive the data in small chunks and retransmit it
request = None
header = self.connection.recv(10)
try:
header = self.connection.recv(10)
except OSError:
# could happen on MacOS
self.log.info("")
break
if len(header) == 0:
# null data received, socket is closing.
self.log.info(f"[{self.timestamp()}] Connection closing.")