title: PHP: stream_socket_server()
body: <p>I have a homebrew PHP TCP chat server, but it doesn't have a way to detect remote disconnects.</p>
  
  <p>I would be grateful if someone knew a way to just take a stream_socket_server() and spit out everything connected to it.</p>
  
  <p>Then you could run a loop like this, in <em>psuedocode</em>: </p>
  
  <pre><code>$main_socket=stream_socket_server("tcp://",....)
  
  //Do Something.... say, wait for a connection (with stream_socket_accept())?
  
  for (each CONNECTION in $main_socket)
  {
  //Do something with or to that connection
  }
  
  //Loop back... if you need to say, wait for another connection
  </code></pre>
  
  <p><strong>Alternatively</strong>, could I check if a variable created with $stream_socket_accept() is presently connected.</p>
  
  <p>This project is bust until I figure this out.  I'd be grateful to anyone who could help me out on this one!</p>