【发布时间】:2016-08-30 09:34:21
【问题描述】:
我正在使用下面的代码尝试将 OSC 消息发送到网络上的计算机。我正在使用一个名为 osc 的包。
我无法向运行 OSC 服务器的机器发送消息,并在尝试发送 OSC 消息时收到以下错误:
Error: Uncaught, unspecified "error" event. (Can't send packets on a closed osc.Port object. Please open (or reopen) this Port by calling open().)
代码
let osc = require('osc');
let oscUDP = new osc.UDPPort({
remoteAddress: "192.168.1.5",
remotePort: 8004
});
oscUDP.send({
address: "/carrier/frequency",
args: 440
});
oscUDP.open();
如果我将oscUDP.open() 放在send 调用之前,我会得到一个不同的错误:
Error: send EINVAL 192.168.1.5:8004
at Object.exports._errnoException (util.js:1007:11)
at exports._exceptionWithHostPort (util.js:1030:20)
at SendWrap.afterSend [as oncomplete] (dgram.js:402:11)
我在 OSX 上运行 OSCulator 作为服务器。上面的代码存在于不同的机器上。当我在 IP 地址上运行 nmap 时,端口是打开的:
nmap 192.168.1.5 -p 8004
Starting Nmap 6.40 ( http://nmap.org ) at 2016-08-30 08:22 BST
Nmap scan report for 192.168.1.5
Host is up (0.13s latency).
PORT STATE SERVICE
8004/tcp open unknown
如果我使用osc-cli,则在运行 OSC 服务器的机器上接收到消息:
osc --host 192.168.1.5:8004 /test 1 2 3
所以看起来问题根本不在于关闭的端口,因为在使用 osc-cli 时会发送和接收消息。
有什么想法吗?
【问题讨论】: