I want to connect Blender (v2.55) to a web page via sockets.
For the web part, I can use Node.js and socket.io. I already used a little Node.js / socket.io, this is not a problem, I think.
Now for Blender, it runs on Python 3.1, so I already have sockets, and I can add libraries if necessary. I'm new to Python sockets, can I directly connect the client to Node.js / socket.io?
I tried using the base code from a Python document:
import socket
import sys
HOST, PORT = "127.0.0.1", 8080
data = "Hello from Blender"
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
sock.send(bytes(data + "\n","utf8"))
received = sock.recv(1024)
sock.close()
print("Sent: %s" % data)
print("Received: %s" % received)
This is the result:
Sent: Hello from Blender
Received: b ''
Blender seems to be connected but not receiving data. In addition, Node shows that the new client is not connected ...
Do I need anything else? If someone can help me ...