hi, long story, but i am trying to use one computer to control another in BGE
basic idea is that i want to have someone hit the spacebar on computer 1 and it starts a top spinning on computer 2, and then makes it spin faster and faster with every press of the spacebar
problem is that the code on computer 2 (the top) causes it to freeze every time i hit ‘p’ to start BGE
it freezes both on windows and mac os x, so i’m pretty sure i’m doing something that python doesn’t like
(this is a real freeze - it’s not like waiting for something to happen and nothing’s happening - on mac, i quickly get the spinning pinwheel of death - on windows, i immediately get the grayed-out screen with ‘not responding’)
so, here’s the code on computer 2 (the top):
import bge
import socket
cont = bge.logic.getCurrentController()
own = cont.owner
spin = cont.actuators[“spin”]
spin.useLocalAngV = True
host = ‘’ # that is two single quotes, by the way, not one double quote
port = 50001
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host,port))
s.listen(1)
spinSpeed = 0
while 1:
client, address = s.accept()
data = client.recv(size)
if data == “spaceBar”:
spinSpeed = spinSpeed + 1
spin.angV = [0, 0, spinSpeed]
cont.activate(spin)
although i don’t think it matters, just in case, here is the code on computer 1 (the computer where you press the spacebar):
import bge
import socket
cont = bge.logic.getCurrentController()
own = cont.owner
hitSpacebar = cont.sensors[“spaceBar”] # this is a spacebar-triggered sensor brick attached to the python controller
host = ‘localHost’
port = 50001
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
if hitSpacebar.positive:
s.send(“spaceBar”)
any thoughts why computer 2 is always freezing when i hit ‘p’?
if it helps, i have found that it does not freeze when i delete the s.listen(1) line, but it doesn’t work either, i just get this error:
Python script error - object ‘Top’, controller ‘Python’:
Traceback (most recent call last):
File “spin.py”, line 73, in <module>
File “/Applications/Blender/blender.app/Contents/MacOS/2.70/python/lib/python3.3/socket.py”, line 135, in accept
fd, addr = self._accept()
OSError: [Errno 22] Invalid argument