final private function send(string $type, string $msg = ''): bool
    {
        if ($this->useExtension) {
            return opencensus_core_send_to_daemonclient(ord($type), $msg);
        }
        $start = microtime(true);
        $maxEnd = $start + $this->maxSendTime;

        $buf = self::START_OF_MSG . $type;
        self::encodeUnsigned($buf, ++$this->seqnr);
        self::encodeUnsigned($buf, \getmypid());
        self::encodeUnsigned($buf, $this->getmytid());
        if ($this->float32) {
            // pad with nulls on both sides (easy to detect on other size)
            $buf .= "\x00\x00" . pack('E', $start) . "\x00\x00";
        } else {
            $buf .= pack('E', $start);
        }
        self::encodeUnsigned($buf, strlen($msg));
        $buf .= $msg;

        $remaining = strlen($buf);
        while ($remaining > 0 && microtime(true) < ($maxEnd)) {
            $c = @fwrite($this->stream, $buf, $remaining);
            if ($c == false) {
                return false;
            }
            $remaining -= $c;
            $buf = substr($buf, $c);
        }
        return ($remaining === 0);
    }
final private function send(string $type, string $msg = ''): bool
    {
        if ($this->useExtension) {
            return opencensus_core_send_to_daemonclient(ord($type), $msg);
        }
        $start = microtime(true);
        $maxEnd = $start + $this->maxSendTime;

        $buf = self::START_OF_MSG . $type;
        self::encodeUnsigned($buf, ++$this->seqnr);
        self::encodeUnsigned($buf, \getmypid());
        self::encodeUnsigned($buf, $this->getmytid());
        if ($this->float32) {
            // pad with nulls on both sides (easy to detect on other size)
            $buf .= "\x00\x00" . pack('E', $start) . "\x00\x00";
        } else {
            $buf .= pack('E', $start);
        }
        self::encodeUnsigned($buf, strlen($msg));
        $buf .= $msg;

        $remaining = strlen($buf);
        while ($remaining > 0 && microtime(true) < ($maxEnd)) {
            $c = @fwrite($this->stream, $buf, $remaining);
            if ($c == false) {
                return false;
            }
            $remaining -= $c;
            $buf = substr($buf, $c);
        }
        return ($remaining === 0);
    }
final private function send ( string $ type , string $ msg = '' ) : bool { if ( $ this -> useExtension ) { return opencensus_core_send_to_daemonclient ( ord ( $ type ) , $ msg ) ; } $ start = microtime ( true ) ; $ maxEnd = $ start + $ this -> maxSendTime ; $ buf = self :: START_OF_MSG . $ type ; self :: encodeUnsigned ( $ buf , ++ $ this -> seqnr ) ; self :: encodeUnsigned ( $ buf , \ getmypid ( ) ) ; self :: encodeUnsigned ( $ buf , $ this -> getmytid ( ) ) ; if ( $ this -> float32 ) { // pad with nulls on both sides (easy to detect on other size) $ buf .= "\x00\x00" . pack ( 'E' , $ start ) . "\x00\x00" ; } else { $ buf .= pack ( 'E' , $ start ) ; } self :: encodeUnsigned ( $ buf , strlen ( $ msg ) ) ; $ buf .= $ msg ; $ remaining = strlen ( $ buf ) ; while ( $ remaining > 0 && microtime ( true ) < ( $ maxEnd ) ) { $ c = @ fwrite ( $ this -> stream , $ buf , $ remaining ) ; if ( $ c == false ) { return false ; } $ remaining -= $ c ; $ buf = substr ( $ buf , $ c ) ; } return ( $ remaining === 0 ) ; }
Send message to daemon

Message layout:
MSG_PREFIX  : 32 bit (0 value to aide in recovery from message truncation)
MESSAGE_TYPE: byte
SEQUENCE_NR : varint
PROCESS_ID  : varint
THREAD_ID   : varint (0 in most PHP deployments - (ZTS disabled))
START_TIME  : float (measured in microseconds, 32 or 64 bit depending on env.)
MSG_LEN     : varint (length of message payload)
MSG         : encoded message of size MSG_LEN

@param string $type The message type (1 byte).
@param string $msg The message payload.
@return bool Returns true on successful operation.
Send message to daemon