views:

58

answers:

1

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?

+1  A: 

See here for a quite nice explanation how it works: http://stackoverflow.com/questions/1499205/amf-message-structure/1557312#1557312

Jan P.
Thanks for the link Jan.
Ben Goosman