Message 1 of 3
Not applicable
01-05-2021
08:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
i am using VRED Pro 2021 [13.0.0.10349] and want to import external data via sockets. Therefore i wrote the following python script:
import socket
import threading
SERVER = socket.gethostbyname(socket.gethostname())
PORT = 5051
ADDR = (SERVER, PORT)
FORMAT = 'utf-8'
DISCONNECT_MESSAGE = "!DISCONNECT"
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(ADDR)
def handle_client(conn, addr😞
print(f"[NEW CONNECTION] {addr} connected.")
connected = True
while connected:
msg = conn.recv(8192).decode(FORMAT)
if msg == DISCONNECT_MESSAGE:
connected = False
print(f"[{addr} {msg}]")
conn.close()
def start():
server.listen()
print(f"[LISTENING] Server is listening on {SERVER}")
while True:
conn, addr = server.accept()
thread = threading.Thread(target=handle_client, args=(conn, addr))
thread.start()
print(f"[ACTIVE CONNECTIONS] {threading.activeCount() -1}")
print ("[STARTING] server is starting")
start()
The script works. I tested it seperatly. Whenever i try to run it, the script-editor and VRED itself freeze.
Does anyone know why?
Solved! Go to Solution.