nodejs buffer 可以写入 64位的吗?

最近遇到个问题 使用 net 模块 与 c++ 那边 进行socket连接
现在 需要传一串 buffer 过去

const buf = Buffer.allocUnsafe(51)

buf.writeInt16BE(0,2)
buf.writeInt32BE(0,4)

官方的api 貌似只提供了 16 和 32 位的,
现在需要拼一个 64位 的 请问怎么写64的呢

我这样尝试下貌似不行

const buf1 = Buffer.allocUnsafe(4)
const buf2 = Buffer.allocUnsafe(4)

const totalLength = buf1.length + buf2.length
console.log(totalLength);

buf1.writeInt32BE(0x0102,0)
buf2.writeInt32BE(0x0304,0)

const uidBuffer = Buffer.concat([buf1,buf2],totalLength)

console.log('uidBuffer',decoder.write(uidBuffer));
阅读 3.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题