WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Sending a value by Thread (https://forum.worldviz.com/showthread.php?t=5232)

Alex Miranda 11-19-2014 06:52 AM

Sending a value by Thread
 
Hello everyone.
I'm using socket and thread on my code and I'm trying to get a value that I have received by thread and put it on my code. My variable is global, but I can't get the result out of the thread.

def recMsg():

global msg

try:
print "Conected!!"

while True:
ip = "localhost"
buffer= 1024
port= 8080
address= (ip,porta)

UDP = socket(AF_INET,SOCK_DGRAM)
UDP.bind(address)

# Recebe mensagens
msg, address= UDP.recvfrom(buffer)

# Encerra o socket
UDP.close()

except:
print "Error"


#Start Thread
try:
thread.start_new_thread(recMsg,())
except:
print "Thread error"


# I would like to print my result here
# print msg for example

Thanks for help me !


All times are GMT -7. The time now is 02:31 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC