Hello,
I got a problem with establishing some simple networking with blender/ge: First some code:
import threading
import socketserver
class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
def handle(self):
self.request.send("bla123".encode())
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
allow_reuse_address = True
if __name__ == "__main__":
HOST, PORT = "192.168.0.2", 5001
server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler)
ip, port = server.server_address
server_thread = threading.Thread(target=server.serve_forever)
server_thread.setDaemon(True)
server_thread.start()
The problem is that sender doesn’t send data over the network in the handle-function when the game-engine is running. This whole script is started by an actuator. After pressing ESC the server thread is still running. Therefore it accepts connections and everything is working fine. The real handle-function reads and writes multiple times in a while loop. Everything works fine after shutting down the GE. But with running GE I can only read data once.
I tried the similar of the example above with UDP but it doesn’t send neither (only when GE is running).
Anyone got an idea what I’m doing wrong? Is there any trick to send data?
Edit: I use blender 2.56
many thanks,
Christian