为什么 AMFPHP 将 AMF 协议的整数存储为两个字节?

发布于 2024-08-13 07:23:28 字数 420 浏览 1 评论 0原文

我想知道熟悉 AMFPHP 或低级数据存储的人是否可以解释为什么整数被存储为两个字节而不是四个字节。据我所知,AMF3 协议需要一个四字节整数。序列化器中的具体代码如下:

/**
 * writeInt takes an int and writes it as 2 bytes to the output stream
 * 0-65535 range
 * 
 * @param int $n An integer to convert to a 2 byte binary string
 */
function writeInt($n) {
    $this->outBuffer .= pack("n", $n); // use pack with the n flag
} 

我意识到这个问题可能太具体了,但是有人可以帮助回答我的问题吗?

I'm wondering if anyone familiar with AMFPHP or low level data storage could explain why integers are being stored as two bytes instead of four. As far as I can tell, the AMF3 protocol demands a four byte integer. The specific code in the serializer is the following:

/**
 * writeInt takes an int and writes it as 2 bytes to the output stream
 * 0-65535 range
 * 
 * @param int $n An integer to convert to a 2 byte binary string
 */
function writeInt($n) {
    $this->outBuffer .= pack("n", $n); // use pack with the n flag
} 

I realize this question may be too specific, but can anyone help answer my question?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城仅有旧梦在 2024-08-20 07:23:28

请参阅此处,了解其工作原理的很好的解释:
AMF 消息结构?

See here for a quite nice explanation how it works:
AMF message structure?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文