This command sends the raw byte data to the network object. This command is useful when communicating with a non-Python based application.
Vizard can also receive raw byte data from other applications. When a raw byte network packet is received a
viz.NETWORK_EVENT is triggered. A
viz.RawNetworkEvent object is passed to the event callback with the following attributes:
address | The IP address of the computer that sent the message. |
port | The port number the message was received on. |
raw_data | The raw byte data that was received, as a Python bytes object. |
network = viz.addNetwork('localhost')
def onKeyDown(key):
if key == ' ':
network.sendRaw('raw data')
viz.callback(viz.KEYDOWN_EVENT,onKeyDown)
def onNetwork(e):
if isinstance(e,viz.RawNetworkEvent):
print(e.raw_data)
viz.callback(viz.NETWORK_EVENT,onNetwork)