[Twisted-Python] send_UDP?

Sven-Erik Tiberg Sven-Erik.Tiberg at ltu.se
Sun Feb 25 14:52:47 EST 2007

Just need a small tip, how to send a string by UDP, should I use socket from python or can I use any twisted class.
Put together a rough code for reciving a string of data from simulink ( matlab ) to a H3D ( Haptic Interactive X3D ) application www.h3d.org
#import H3D fields and types
from H3DInterface import *
recived_vect = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
class Set_Position( AutoUpdate( SFVec3f ) ):
 def update( self,event ):
  set_pos[1] = recived_vect[2]
  set_pos[2] = recived_vect[3]
  set_pos[3] = recived_vect[4]
  return set_pos
class Speedo_value( AutoUpdate( SFVec3f ) ):
 def update( self,event ):
  set_rot[1] = 0.0
  set_rot[2] = 0.0
  set_rot[3] = recived_vect[1]
  return set_rot
from twisted.internet.protocol import DatagramProtocol
from twisted.internet import reactor
class Recive_UDP_Package(DatagramProtocol):
 def datagramRecived(self, data):
  recived_vect=data # need to work on this to convert the data string to list element
reactor.listenUDP(7999, Recived_UDP_Package())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 4471 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20070225/19bb7446/attachment.bin 

More information about the Twisted-Python mailing list