PHP文本流/缓冲区,用于在脚本之间共享实时数据

PHP stream_socket_server/client with local file access issue.

I'm using a modification of this script: php: How to save the client socket (not closed), so a further script may retrieve it to send an answer? but I cannot get the local file portion to work properly.

What I'm trying to do is essentially stream data between PHP processes/scripts by using a file as a middle-man, essentially streaming data.

I'm having trouble with the existing script where I'm opening/adding to the existing file.

On the stream_socket_server side, it'll work once (file doesn't exist), but then throws the error below on any subsequent attempt to run;

PHP Warning: stream_socket_server(): unable to connect to unix://./temp.sock (Unknown error)

Seems that when the stream_socket_server creates the file, it makes it as read only with details in the snippet below;

rwxrwxr-x 1 xxx xxx    0 Jun 13 20:05 temp.sock

I've tried adjusting the permissions to something more forgiving, but no luck.

On the socket client side, I cannot ever get it to open the file, existing or not.

$socket = stream_socket_server('unix://./temp.sock', $errno, $errstr);
$sock = stream_socket_client('unix:///./temp.sock', $errno, $errstr);

PHP Warning: stream_socket_server(): unable to connect to unix://./temp.sock (Unknown error) (server when file already exists)

PHP Warning: stream_socket_client(): unable to connect to unix://./temp.sock (Connection refused) (client)