我正在尝试将一个简单的udp组播数据包发送到chrome app中的255.255.255.255。我能够获得常规的udp数据包发送,但是一旦我尝试广播地址,我就会在运行sockets.udp.send时获得'未经检查的runtime.lastError:net :: ERR_ACCESS_DENIED'
我的清单看起来像
{
"manifest_version": 2,
"name": "UDP Multicast",
"description": "udp",
"version": "0.0.1",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": { "16": "icon.png" },
"sockets": {
"udp": {
"send": "*",
"bind": "*"
}
},
"permissions": [
{"socket": ["udp-bind", "udp-send-to"]}
]
}
和我的background.js
chrome.app.runtime.onLaunched.addListener(function() {
// chrome.app.window.create('window.html', {
// 'bounds': {
// 'width': 400,
// 'height': 500
// }
// });
chrome.sockets.udp.create({}, function(socketInfo) {
var socketId = socketInfo.socketId;
var arrayBuffer = new ArrayBuffer(6);
var buffer = new Uint16Array(arrayBuffer);
buffer[0] = 0x2e
buffer[1] = 0x2c
buffer[2] = 0x3a
buffer[3] = 0x01
buffer[4] = 0x00
buffer[5] = 0x00
chrome.sockets.udp.bind(socketId, "0.0.0.0", 0, function(result) {
chrome.sockets.udp.send(socketId, buffer.buffer, '255.255.255.255', 4201, function(sendInfo) {
console.log("sent ", sendInfo.bytesSent);
});
});
});
});