从PHP连接到UNIX套接字时出错

从PHP连接到UNIX套接字时出错,php,unix-socket,Php,Unix Socket,每当我运行代码以附加到unix套接字时,都会出现以下错误: PHP警告:流\u套接字\u服务器():无法连接到unix:///var/run/pf_log.sock (未知错误) 以下是代码块: $firewall_log = stream_socket_server("unix:///var/run/pf_log.sock", $errno, $errstr); if (!$firewall_log) { echo 'data: ' . $

每当我运行代码以附加到unix套接字时,都会出现以下错误: PHP警告:流\u套接字\u服务器():无法连接到unix:///var/run/pf_log.sock (未知错误)

以下是代码块:

$firewall_log = stream_socket_server("unix:///var/run/pf_log.sock", $errno, $errstr);

if (!$firewall_log) {
                echo 'data: ' . $errstr . '(' . $errno . ')' . '\n\n';
        }
        else {
                // while there is connection, i'll receive it... if I didn't receive a message within $nbSecondsIdle seconds, the following function will stop.
                while ($conn = @stream_socket_accept($firewall_log, -1)) {
                        $message= fgets($conn);
                        echo 'data : '.$message . "\n\n";
                }
                fclose ($conn);
                fclose($firewall_log);
        }
如果有人有任何想法,请让我知道。。。 提前谢谢


标记

Hm,未知错误。可能是权限问题,请确保您的用户对
/var/run
具有r和x权限。