gpt4 book ai didi

node.js - Node js 0.10.7 : cluster support for udp dgram?

转载 作者:IT老高 更新时间:2023-10-28 23:17:38 26 4
gpt4 key购买 nike

我正在尝试运行下面提到的 Node js 应用程序 https://github.com/joyent/node/issues/2194

var util = require("util"),
dgram = require("dgram"),
cluster = require('cluster');

var udp = dgram.createSocket("udp4");
var port = 1190;

if (cluster.isMaster) {
for (i = 0; i < 2; i++) {
cluster.fork();
}
} else {
util.log("starting udp server on port " + port);
udp.on("error", function (error) {
util.log("failed to bind to UDP port - " + error)
});
udp.bind(port);
}

应用程序立即退出,输出如下:

23 May 23:22:13 - starting udp server on port 1190
23 May 23:22:13 - starting udp server on port 1190

events.js:72
throw er; // Unhandled 'error' event
^
Error: write ENOTSUP - cannot write to IPC channel.
at errnoException (child_process.js:980:11)
at ChildProcess.target.send (child_process.js:455:16)
at Worker.send (cluster.js:401:21)
at sendInternalMessage (cluster.js:394:10)
at handleResponse (cluster.js:177:5)
at respond (cluster.js:192:5)
at Object.messageHandler.queryServer (cluster.js:242:5)
at handleMessage (cluster.js:197:32)
at ChildProcess.EventEmitter.emit (events.js:117:20)
at handleMessage (child_process.js:318:10)

有人知道发生了什么吗?在没有集群的情况下运行它时,一切都很好。集群好像不支持udp?

一些规范:

Window 7 x64
node js 0.10.7

最佳答案

它在您提供的链接中说,在 v0.11.14 中添加了对 UDP 集群的支持。您可能只需要更新 node.js 的版本

关于node.js - Node js 0.10.7 : cluster support for udp dgram?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16724216/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com