Network doesn't send when GE is running

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

Hi Christian! Have you heard about Old Jim’s project?

Don’t forget to check it out, it should interest you:

1) http://www.oldjim.ch/OJW-HP/php/home/index.php?en=wsag.html

2) http://wiki.blender.org/index.php/Doc:2.4/Books/GameKit_2/09.Basic_Networking

Hi ChicOrtiz,

thanks for the answer. Yes, I found these pages. My problem was that all these examples don’t explain the general problem that one have to use asyncronous IO and the dispatching has to be done manually. I got the tip to use asyncore for this and now it seems to work! :slight_smile:

regards,
Christian