function header_and_body() { $body = $this->body(); // Get body first, we will need it's length $tag = chr($this->tag | 0xc0); // First two bits are 1 for new packet format $size = chr(255) . pack('N', strlen($body)); // Use 5-octet lengths return array('header' => $tag . $size, 'body' => $body); }