title: How to access to socket object from a different php file
body: <p>I want to send something to my connected clients over another php script. But when I use the function "send", clientlist is null.
  Can you help me about this please?</p>
  
  <p>Socket.php:</p>
  
  <pre><code>$clientlist = array();
  
  function run() {
      global $clientlist;
  
      set_time_limit(0);
      $address = '127.0.0.1';
      $port = 80;
      $sock = socket_create(AF_INET, SOCK_STREAM, 0); 
  
      socket_bind($sock, 0, $port) or die('Could not bind to address'); 
      socket_listen($sock);
  
      printf("Listening...\r\n");
  
      while (true) {
          $client = socket_accept($sock);
          $input = socket_read($client, 1024000);
  
          $clientlist[] = $client;
      }
  }
  
  function send($msg) {
      global $clientlist;
      printf("Count: " . count($clientlist) . "\r\n");
      socket_write($clientlist[0], "Hey");
  }
  </code></pre>
  
  <p>Msg.php:</p>
  
  <pre><code>include("socket.php");
  
  send($_GET['msg']);
  </code></pre>