我正在尝试通过以下方式向客户发送消息:
server.send(new Buffer("Hello World!"), data.port, data.ip);
但我总是收到以下错误:
dgram.js:256
throw new RangeError('Offset into buffer too large');
^
RangeError: Offset into buffer too large
at Socket.send (dgram.js:256:11)
at Socket.<anonymous> (/home/lchost/fishy.io/server/custom_modules/game.js:50:14)
at Socket.emit (events.js:98:17)
at UDP.onMessage (dgram.js:441:8)
任何想法我做错了什么?
答案 0 :(得分:0)
我应该这样做:
server.send(new Buffer("Hello World!"), 0, 0, data.port, data.ip);
答案 1 :(得分:0)
var data = new Buffer("Hello World!");
server.send(data, 0, data.length, data.port, data.ip);
在节点 v0.10.29 中测试