title: PHP Text Stream/Buffer to share real-time data between scripts
body: <p>PHP stream_socket_server/client with local file access issue.</p>
  
  <p>I'm using a modification of this script: <a href="https://stackoverflow.com/questions/27425846/php-how-to-save-the-client-socket-not-closed-so-a-further-script-may-retriev">php: How to save the client socket (not closed), so a further script may retrieve it to send an answer?</a> but I cannot get the local file portion to work properly.</p>
  
  <p>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.</p>
  
  <p>I'm having trouble with the existing script where I'm opening/adding to the existing file.</p>
  
  <p>On the <code>stream_socket_server</code> side, it'll work once (file doesn't exist), but then throws the error below on any subsequent attempt to run;</p>
  
  <blockquote>
    <p>PHP Warning:  stream_socket_server(): unable to connect to unix://./temp.sock (Unknown error)</p>
  </blockquote>
  
  <p>Seems that when the <code>stream_socket_server</code> creates the file, it makes it as read only with details in the snippet below;</p>
  
  <pre><code>rwxrwxr-x 1 xxx xxx    0 Jun 13 20:05 temp.sock
  </code></pre>
  
  <p>I've tried adjusting the permissions to something more forgiving, but no luck.  </p>
  
  <p>On the socket client side, I cannot ever get it to open the file, existing or not.  </p>
  
  <pre><code>$socket = stream_socket_server('unix://./temp.sock', $errno, $errstr);
  $sock = stream_socket_client('unix:///./temp.sock', $errno, $errstr);
  </code></pre>
  
  <blockquote>
    <p>PHP Warning:  stream_socket_server(): unable to connect to unix://./temp.sock (Unknown error) (server when file already exists)</p>
    
    <p>PHP Warning:  stream_socket_client(): unable to connect to unix://./temp.sock (Connection refused) (client)</p>
  </blockquote>