Vizard 7 » Command Index » Vizard objects » network » <network>.sendRaw
7.7

<network>.sendRaw

Send raw byte data to the network object

<network>.sendRaw(  
data  
)  
data
The raw byte data to send

Remarks

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:

Event attribute

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.

Return Value

None

Example

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)

See also

<network>.send