为什么 AMFPHP 将 AMF 协议的整数存储为两个字节?
我想知道熟悉 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅此处,了解其工作原理的很好的解释:
AMF 消息结构?
See here for a quite nice explanation how it works:
AMF message structure?