我正在尝试 UnetStack 手册中指定的 python 代码。在运行tx.py和rx.py时,当我在终端上打印出 UnetSocket 对象时,它已成功创建,但 send() 函数在接收器处发送 Nonetype 数据。
tx.py ===>>
from unetpy import UnetSocket
s = UnetSocket('localhost',1101)
print(s)
s.send('hellooo',31)
s.close()
rx.py =====>>>
from unetpy import UnetSocket
s = UnetSocket('localhost',1102)
rx = s.receive()
print('here ',rx)
print('from node : ',bytearray(rx.data).decode())
s.close()
首先我在模拟器上运行 2-node-network.groovy。然后来自终端的 rx.py 和下一个 tx.py。
rx.py Traceback 错误(最近一次调用最后一次):文件“rx.py”,第 6 行,在
print('from node : ',bytearray(rx.data).decode())
AttributeError: 'NoneType' object has no attribute 'data'
O/p at tx.py <unetpy.UnetSocket object at 0x7fe2909d4550>