why does this script "Freeze" the game engine?

Hi guys! this script I made is working 100% in the python console, but when i run it inside of the game engine it freezes. still thoe the script is working in the bge console.
any ide’s on how I can fix the freezing prob?

Here is my script:


import socket
import pickle
client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client_socket.bind(("", 3500))
v2 = 1
players = ""
text = " "
while v2 == 1:
    data, address = client_socket.recvfrom(256)
    UPData = pickle.loads(data)
    print (UPData)
    players = UPData[0][0]    # this line is the one python tells me is bad
    text = UPData[0][1]
    ge = str(text, "latin-1")
    print ("the ip :" , ge)
client_socket.close()

EDIT: forgot to tell that i’m runing blender 2.61

Did you try localizing the problem by putting print() statements everywhere?

-rking

SOLVED IT !! i nneded to add the line:socket.setblocking(0) inorder 4 the script to end even if there where no data

Hello! Can you hang the complete and corrected code. I still dont get it!