public function scan_data_execute_unixsocket($data) {
        $socket = stream_socket_client('unix://' . $this->get_config('pathtounixsocket'), $errno, $errstr, ANTIVIRUS_CLAMAV_SOCKET_TIMEOUT);
        if (!$socket) {
            // Can't open socket for some reason, notify admins.
            $notice = get_string('errorcantopensocket', 'antivirus_clamav', "$errstr ($errno)");
            $this->set_scanning_notice($notice);
            return self::SCAN_RESULT_ERROR;
        } else {
            // Initiate data stream scanning.
            // Using 'n' as command prefix is forcing clamav to only treat \n as newline delimeter,
            // this is to avoid unexpected newline characters on different systems.
            fwrite($socket, "nINSTREAM\n");
            // Send data in chunks of ANTIVIRUS_CLAMAV_SOCKET_CHUNKSIZE size.
            while (strlen($data) > 0) {
                $chunk = substr($data, 0, ANTIVIRUS_CLAMAV_SOCKET_CHUNKSIZE);
                $data = substr($data, ANTIVIRUS_CLAMAV_SOCKET_CHUNKSIZE);
                $size = pack('N', strlen($chunk));
                fwrite($socket, $size);
                fwrite($socket, $chunk);
            }
            // Terminate streaming.
            fwrite($socket, pack('N', 0));

            $output = stream_get_line($socket, 4096);
            fclose($socket);

            // Parse the output.
            return $this->parse_unixsocket_response($output);
        }
    }