Swoole Server getClientList

public array Swoole\Server::getClientList ( integer $start_fd [, integer $pagesize ] )

Get the list of all the TCP connections for all the workers.

this method is besed on the shared memory and is fast.

Parameter

  • $start_fd the start id number of client list
  • $pagesize the pagesize of list

Return

The array list of the $fd client

If fail, the result is FALSE.

Example

<?php
$start_fd = 0;
while(true)
{
    $conn_list = $server->getClientList($start_fd, 10);
    if($conn_list===false or count($conn_list) === 0)
    {
        echo "finish\n";
        break;
    }
    $start_fd = end($conn_list);
    var_dump($conn_list);
    foreach($conn_list as $fd)
    {
        $server->send($fd, "broadcast");
    }
}