title: pthreads how to destroy finished socket connections
body: <p>I have code as following, using php7-zts and pthreads. I'm wondering how to clean up the finished Client properly so I don't have a memory leak.</p>
  
  <pre><code>&lt;?php
  
  class Client extends Thread {        
      public function __construct($socket){
          $this-&gt;socket = $socket;
          $this-&gt;start();
      }
      public function run(){                
          $msgsock = $this-&gt;socket;
          if ($msgsock) { 
              if (false === ($buf = socket_read($msgsock, 2048, PHP_BINARY_READ))) {
                  echo "socket_read() failed: reason: " . socket_strerror(socket_last_error($msgsock)) . "\n";
              }
  
              ......
  
              $write_result = socket_send($msgsock, $result, strlen($result), MSG_EOF);
              socket_close($msgsock);    
              //finished                    
          }            
      }
  }
  
  ...
  //create, bind, and listen $sock
  ...
  
  while(($client = socket_accept($sock))){
      $clients[]=new Client($client); 
  } 
  
  ?&gt;
  </code></pre>