Blender-Pipeline/network/read_messages.py

37 lines
712 B
Python
Raw Normal View History

# GNU General Public License
# This script is for developers of VCStudio rendering. This will read any
# message on 127.0.0.1 port 54545
import socket
UDP_IP = "127.0.0.1"
UDP_PORT = 54545
prev = ""
while True:
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind((UDP_IP, UDP_PORT))
sock.settimeout(0.05)
data, addr = sock.recvfrom(1024)
data = data.decode('utf8')
if prev != str(data):
print("<<< "+str(data))
prev = str(data)
sock.close()
except:
pass