我正在尝试通过OSC (Open Sound Control) 协议在Chuck和 python之间建立通信。在 python 方面,我们使用python-osc 库,并且chuck 原生支持 OSC 协议。看来我们从 python 端发送的消息没有到达chuck 端。所有其他组合,即 python 到 python、chuck 到chuck 和chuck 到 python 都可以正常工作。我在 Windows 7 上运行 python 3.4.4。这里可能出了什么问题?
这是我用于测试的客户端/服务器实现的四个文件。
夹头客户端.py:
OscSend xmit;
xmit.setHost("localhost", 5005);
<<<"Sending">>>;
xmit.startMsg("/debug");
夹头服务器.py:
OscRecv orec;
5005 => orec.port;
orec.listen();
orec.event("/debug") @=> OscEvent e;
<<<"Waiting">>>;
e => now;
<<<"Received">>>;
python_client.py:
from pythonosc import osc_message_builder
from pythonosc import udp_client
client = udp_client.UDPClient('localhost', 5005)
msg = osc_message_builder.OscMessageBuilder(address="/debug")
msg = msg.build()
print('Sending')
client.send(msg)
python_server.py:
from pythonosc import dispatcher
from pythonosc import osc_server
dispatcher = dispatcher.Dispatcher()
dispatcher.map("/debug", lambda _: print('Received'))
print('Waiting')
server = osc_server.ThreadingOSCUDPServer(
('localhost', 5005), dispatcher)
print("Serving on {}".format(server.server_address))
server.serve_forever()