开发者

Why does AMFPHP store integers as two bytes for the AMF protocol?

开发者 https://www.devze.com 2022-12-13 02:20 出处:网络
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

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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消