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);
}