/** * get an EPP frame from the remote peer * @param resource $socket a socket connected to the remote peer * @throws Exception on frame errors. * @return string the frame */ static function getFrame($socket) { // Read header $hdr = Net_EPP_Protocol::_fread_nb($socket, 4); if (strlen($hdr) < 4) { throw new Exception(sprintf('Short read of %d bytes from peer', strlen($hdr))); } // Unpack first 4 bytes which is our length $unpacked = unpack('N', $hdr); $length = $unpacked[1]; if ($length < 5) { throw new Exception(sprintf('Got a bad frame header length of %d bytes from peer', $length)); } else { $length -= 4; // discard the length of the header itself // Read frame return Net_EPP_Protocol::_fread_nb($socket, $length); } }