/**
  * Check if the message is well formed
  * 
  * @param string        $msg   The message
  * 
  * @param CInteropActor $actor The actor who sent the message
  * 
  * @return boolean
  */
 function isWellFormed($msg, CInteropActor $actor = null)
 {
     $stream = fopen("php://temp", 'w+');
     fwrite($stream, $msg);
     $stream_reader = new CDicomStreamReader($stream);
     $stream_reader->rewind();
     $type = $stream_reader->readHexByte();
     if ($type != "04") {
         $stream_reader->close();
         return false;
     }
     $stream_reader->skip(1);
     $length = $stream_reader->readUInt32();
     $stream_reader->close();
     if (strlen($msg) != $length + 6) {
         return false;
     }
     return true;
 }