Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Windows上发送数据报时发生EACCES错误_Windows_Node.js_Sockets_Udp - Fatal编程技术网

在Windows上发送数据报时发生EACCES错误

在Windows上发送数据报时发生EACCES错误,windows,node.js,sockets,udp,Windows,Node.js,Sockets,Udp,我的程序在执行dgram.udp4套接字的send()方法时抛出EACCES错误,但仅在Windows上执行 守则: var dgram = require('dgram'); var monsocket = dgram.createSocket("udp4"); monsocket.on("listening", function () { comBroadcastCallUp(); }); var comBroadcastCallUp = function()

我的程序在执行dgram.udp4套接字的send()方法时抛出EACCES错误,但仅在Windows上执行

守则:

var dgram       = require('dgram');

var monsocket   = dgram.createSocket("udp4");

monsocket.on("listening", function () {     comBroadcastCallUp(); });

var comBroadcastCallUp = function() {
    var message = new Buffer(JSON.stringify({ 
        protocol: "psdp", 
        command: "call-up" 
    }));

    monsocket.setBroadcast(true);
    monsocket.send(message, 0, message.length, 32681, '255.255.255.255', function (err) {
        if (err) console.log(err)
            else console.log("<PcStatus:PSDP> Message sent: " + message + os.EOL + "Message length: " + message.length);
    });
    monsocket.setBroadcast(false);
}

monsocket.bind(32681);
Linux上的终端输出:

<PcStatus:PSDP> Message sent: {"protocol":"psdp","command":"call-up"}
Message length: 39
发送的信息:{“协议”:“psdp”,“命令”:“调用”} 信息长度:39
我检查了防火墙,如果其他程序使端口忙,那么从Windows 7开始,我认为不再支持向
255.255.255.255
广播任何内容。您需要将发送限制为特定子网


另外请记住,并非所有路由器都将路由发送到
255.255.255.255

的数据包。您是否也尝试在Windows上以管理员身份运行节点,以查看这是否会产生影响?
<PcStatus:PSDP> Message sent: {"protocol":"psdp","command":"call-up"}
Message length: 39