PHP Class morozovsk\websocket\Server

Datei anzeigen Open project: morozovsk/websocket

Public Methods

Method Description
__construct ( $config )
restart ( )
start ( )
stop ( ) *protected function spawnWorkers() { $master = null; $workers = array();

Method Details

__construct() public method

public __construct ( $config )

restart() public method

public restart ( )

start() public method

public start ( )

stop() public method

for ($i=0; $i<$this->config['master']['workers']; $i++) { create a pair of sockets through which the master and the worker is to be linked $pair = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP); $pid = pcntl_fork();//create a fork if ($pid == -1) { die("error: pcntl_fork\r\n"); } elseif ($pid) { //master fclose($pair[0]); $workers[intval($pair[1])] = $pair[1];//one of the pair is in the master } else { //worker fclose($pair[1]); $master = $pair[0];//second of pair is in worker break; } } return array($pid, $master, $workers); }
public stop ( )