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);
    }